I'm hard pressed to imagine how this couldn't be done efficiently. Do you have an example which correctly solves the problem but takes too long?
The only thing I can think of is something like the output rewriting an array on update over and over.
The only thing I can think of is something like the output rewriting an array on update over and over.
Behold
var AGESORT = rows.bubblesort("AGE ASCENDING")
var AGESORT1 = rows.bubblesort("AGE DESCENDING")
var MALE = "None"
var MALE1 = "None"
for row in AGESORT
if row.isMale
MALE = row
break
for row in AGESORT1
if row.isMale
MALE1 = row
break
print "Min age: " + MALE
print "Max age: " + MALE1
Stuff like this is usually the result of thoughts like "Ok, I'll break this problem into two, then combine the pieces. First I'll find the minimum age, which is easy once I sort the rows. Done. Ok, now I can see I can slightly alter that code so that it finds the max age! Now, I just put the pieces of code together, and do a little code organization to put like with like. I"For the "find the min and max of a set" in particular, a lot of folks start out with terrible solutions.