Package ca.cgjennings.text
Class LineSorter
- java.lang.Object
-
- ca.cgjennings.text.LineSorter
-
- Direct Known Subclasses:
LineSorter.LocalizedSorter
public class LineSorter extends java.lang.ObjectSorts a set of lines using various mechanisms. The base class sorts in lexicographic order.- Author:
- Chris Jennings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLineSorter.LocalizedSorterA line sorter that uses a locale-specific sorting order.static classLineSorter.SemanticSorterprotected static interfaceLineSorter.TaggedLine
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Comparator<java.lang.Object>comparatorSubclasses can set this to modify the sort order or to apply special sorting based on line tagging.
-
Constructor Summary
Constructors Constructor Description LineSorter()LineSorter(boolean descending)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LineSorter.TaggedLine[]prepSort(java.lang.String[] lines)java.lang.String[]sort(java.lang.String[] lines)Sorts an array of strings.protected java.lang.String[]sortTagged(java.lang.String[] lines, LineSorter.TaggedLine[] tagged, java.util.Comparator cmp)
-
-
-
Method Detail
-
sort
public java.lang.String[] sort(java.lang.String[] lines)
Sorts an array of strings. Depending on the details of the algorithm, the returned array may or may not be the same.- Parameters:
lines- the strings to sort- Returns:
- the original strings, in sorted order
-
prepSort
protected LineSorter.TaggedLine[] prepSort(java.lang.String[] lines)
-
sortTagged
protected java.lang.String[] sortTagged(java.lang.String[] lines, LineSorter.TaggedLine[] tagged, java.util.Comparator cmp)
-
-