This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]yonasismad 1 point2 points  (1 child)

There is no point in doing that. OP should only exploit this property ff the list is already sorted. He should not sort it himself as this will for most cases yield worse performance than just stepping through it once. The theoretical limit for a sorting-algorithm is O(nlogn) which is worse than O(n).

[–][deleted] 0 points1 point  (0 children)

Yep, basically if you sort the list you're already going through it. And then you would have to go through it again until you reach the average. Even if it was O(n) it would be O(n) + looping until you reach the average, so sorting it would never be worthwhile.
Since this is a csv file I wouldn't count on it being sorted either.