sort

sort list-of-numbers
sort list-of-strings
sort agentset

If the input is a list of numbers or strings, reports a new list containing the same items as the input list, but in ascending order (numeric or alphabetic).

Any list items that are not numbers or strings are ignored. (If the input list contains no numbers or strings, the result is an empty list.)

If the input is an agentset or a list of agents, reports a list (never an agentset) of agents. If the agents are turtles, they are listed in ascending order by who number. If the agents are patches, they are listed left-to-right, top-to-bottom.

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

Take me to the full NetLogo Dictionary