Difference between revisions of "Sort in reverse order"

From CodeCodex

(Erlang)
(Implementations)
 
Line 17: Line 17:
 
   ary.sort.reverse
 
   ary.sort.reverse
 
end
 
end
 +
</pre>
 +
 +
=== Tcl ===
 +
<pre class="tcl">
 +
lsort -decreasing [list 7 6 9 2 3 1 ]
 
</pre>
 
</pre>
  
Line 22: Line 27:
 
[[Category:Java]]
 
[[Category:Java]]
 
[[Category:Ruby]]
 
[[Category:Ruby]]
 +
[[Category:Tcl]]
 
[[Category:Arrays]]
 
[[Category:Arrays]]
 +
[[Category:Sorting]]

Latest revision as of 20:24, 3 March 2011

Implementations[edit]

Erlang[edit]

reverse_sort(List) ->
    lists:reverse( lists:sort(List) ).

Java[edit]

Arrays.sort (myArray, Collections.reverseOrder());

Ruby[edit]

def reverse_sort(ary)
  ary.sort.reverse
end

Tcl[edit]

lsort -decreasing [list 7 6 9 2 3 1 ]