Optimization can be tricky
hh
hh at hyperhh.de
Tue Jun 12 16:39:15 EDT 2018
The scenario Geoff described is roughly to get the
top ten (a handful) of 2000 records comparing a certain
numeric value of each.
To get that unknown value of each one has to go once through
all the records *and then sort* for that ranking.
(LiveCode is very fast with a simple numeric sort!)
Any other method of ranking while going through the data
will generously waste CPU time.
> Curry wrote:
> Put yourself in the computer's shoes, and also clarify what you need to
> accomplish. You are asking it to sort the entire list of 2000 records,
> but (if I understand) you only want a handful of those.
>
> And it has already gone through all the records once before the sort. If
> you asked a human to do that, it would be a risky interaction. There
> might be raised voices when they present the neatly arranged file
> cabinet with files in a special order, and you deliver the punch line
> that you only need to pull a few. If you only need to pull 5 records,
> most people don't want to go through all 2000 files - twice.
>
> So generally, don't use a sort after doing a complete loop on a big text
> list, use another method. Do unto your computer as you hope it will do
> unto you when they run the world. :)
More information about the use-livecode
mailing list