Sort an integer array: Difference between revisions

Content added Content deleted
No edit summary
(+Icon+Unicon)
Line 269: Line 269:
=={{header|IDL}}==
=={{header|IDL}}==
<lang idl>result = array[sort(array)]</lang>
<lang idl>result = array[sort(array)]</lang>

== Icon and Unicon ==
Icon and Unicon lists allow mixed type and the built-in function 'sort' will deal with mixed type arrays by sorting by type first then value. Integers sort before, reals, strings, lists, tables, etc. As a result a list of mixed numeric valuess (i.e. integers and reals) will not sort by numeric value, rather the reals will appear after the integers. Sort returns a sorted copy of it's argument. It will also perform some type conversion, such converting an unordered set into an ordered list.
==={{header|Icon}}===
In the example below, L will remain an unsorted list and S will be sorted.
<lang Icon>S := sort(L:= [63, 92, 51, 92, 39, 15, 43, 89, 36, 69]) # will sort a list</lang>
==={{header|Unicon}}===
The Icon solution works in Unicon.


=={{header|J}}==
=={{header|J}}==