### sort

#### sort list
sort agentset

Reports a sorted list of numbers, strings, or agents.

If the input contains no numbers, strings, or agents, the result is the empty list.

If the input contains at least one number, the numbers in the list are sorted in ascending order and a new list reported; non-numbers are ignored.

Or, if the input contains at least one string, the strings in the list are sorted in ascending order and a new list reported; non-strings are ignored.

Or, if the input is an agentset or a list containing at least one agent, a sorted list of agents (never an agentset) is reported; non-agents are ignored. Agents are sorted in the same order the < operator uses.

    show sort [3 1 4 2]
    => [1 2 3 4]
    let n 0
    foreach sort patches [
      ask ? [
        set plabel n
        set n n + 1
      ]
    ]
    ;; patches are labeled with numbers in left-to-right,
    ;; top-to-bottom order

See also sort-by, sort-on.

Take me to the full NetLogo Dictionary