Class LineSorter

  • Direct Known Subclasses:
    LineSorter.LocalizedSorter

    public class LineSorter
    extends java.lang.Object
    Sorts a set of lines using various mechanisms. The base class sorts in lexicographic order.
    Author:
    Chris Jennings
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Comparator<java.lang.Object> comparator
      Subclasses 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • comparator

        protected java.util.Comparator<java.lang.Object> comparator
        Subclasses can set this to modify the sort order or to apply special sorting based on line tagging.
    • Constructor Detail

      • LineSorter

        public LineSorter()
      • LineSorter

        public LineSorter​(boolean descending)
    • 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
      • sortTagged

        protected java.lang.String[] sortTagged​(java.lang.String[] lines,
                                                LineSorter.TaggedLine[] tagged,
                                                java.util.Comparator cmp)