Sort using a custom comparator: Difference between revisions

m
Line 2,135:
|strings|sample|sorted|Here|some|are|be|to|
+-------+------+------+----+----+---+--+--+</lang>
 
Generally speaking, J uses the concept of sorting against a normalized content (which is what <code>length_and_lex</code> provided in the above example). This eliminates a class of errors (which might be conceptualized by using a custom comparator which generates a random number: order would be non-deterministic and sorted order would depend on details of the sorting algorithm) and supports O(n) sorting algorithms such as bin sort (which cannot use comparators).
 
=={{header|Java}}==
6,951

edits