avva: (Default)
[personal profile] avva
Ох, Adobe, Adobe...
Problem Summary

I'd like to determine the max value in an array, but I don't want to have to loop through the array and check each value.

Solution Summary

Put the array in an ArrayCollection, sort the collection, and then get the last value.

Гвозди бы делать из этих людей,
Всё б развалилось от этих гвоздей.

Date: 2009-01-13 04:06 pm (UTC)
From: (Anonymous)
Мне когда надо "десять наибольших элементов" так и делаю, хотя где-то есть функция которая позволяет это делать более эффективно чем сортировка, на больших N ( heapq.nlargest, но это ж идти в начало файла и делать там import heapq !)

( как на самом деле быстрее не знаю, так как модуль на Python, в отличие от sorted которая встроена в интерпретатор )
:)

December 2025

S M T W T F S
  123 4 56
78 9 10 11 1213
1415 1617181920
21 22 23 24 2526 27
28293031   

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 29th, 2025 06:11 pm
Powered by Dreamwidth Studios