### sort-on

#### sort-on [reporter] agentset

Reports a list of agents, sorted according to each agent's value for reporter. Ties are broken randomly.

The values must be all numbers, all strings, or all agents of the same type.

    crt 3
    show sort-on [who] [turtles]
    => [(turtle 0) (turtle 1) (turtle 2)]
    show sort-on [(- who)] [turtles]
    => [(turtle 2) (turtle 1) (turtle 0)]
    foreach sort-on [size] turtles
      [ ask ? [ do-something ] ]
    ;; turtles run "do-something" one at a time, in
    ;; ascending order by size

See also sort, sort-by.

Take me to the full NetLogo Dictionary