If the input is a list, reports a new list containing the same items as the input list, in a sorted order defined by the boolean (true or false) reporter.
In reporter, use ?1 and ?2 to refer to the two objects being compared. reporter should be true if ?1 comes strictly before ?2 in the desired sort order, and false otherwise.
If the input is an agentset or a list of agents, reports a list (never an agentset) of agents.
The sort is stable, that is, the order of items considered equal by the reporter is not disturbed.
show sort-by [?1 < ?2] [3 1 4 2] => [1 2 3 4] show sort-by [?1 > ?2] [3 1 4 2] => [4 3 2 1] show sort-by [length ?1 < length ?2] ["Grumpy" "Doc" "Happy"] => ["Doc" "Happy" "Grumpy"] foreach sort-by [[size] of ?1 < [size] of ?2] turtles [ ask ? [ do-something ] ] ;; turtles run "do-something" one at a time, in ;; ascending order by size
Take me to the full NetLogo Dictionary