weka.knowledgeflow.steps

## Class Sorter.SortRule

- java.lang.Object
- - weka.knowledgeflow.steps.Sorter.SortRule

- All Implemented Interfaces:
    java.util.Comparator<weka.knowledgeflow.steps.Sorter.InstanceHolder>
  Enclosing class:
    Sorter

      public static class Sorter.SortRule
      extends java.lang.Object
      implements java.util.Comparator<weka.knowledgeflow.steps.Sorter.InstanceHolder>

  Implements a sorting rule based on a single attribute

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SortRule()` Constructor
    `SortRule(java.lang.String setup)` Constructor
    `SortRule(java.lang.String att, boolean descending)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compare(weka.knowledgeflow.steps.Sorter.InstanceHolder o1, weka.knowledgeflow.steps.Sorter.InstanceHolder o2)` Compare two instances according to the rule
    `java.lang.String` | `getAttribute()` Get the name or index of the attribute to sort on
    `boolean` | `getDescending()` Return true if the sort is descending
    `void` | `init(Environment env, Instances structure)` Initialize the rule
    `void` | `setAttribute(java.lang.String att)` Set the name or index of the attribute to sort on
    `void` | `setDescending(boolean d)` Set whether the sort should be descending rather than ascending
    `java.lang.String` | `toString()` Prints the rule in human readable format
    `java.lang.String` | `toStringInternal()` Gets the rule in internal format

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Comparator

      `comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- - ### Constructor Detail

    - #### SortRule

          public SortRule(java.lang.String att,
                          boolean descending)

      Constructor
      Parameters:
        `att` - the name or index of the attribute to compare on
        `descending` - true if order should be descending

    - #### SortRule

          public SortRule()

      Constructor

    - #### SortRule

          public SortRule(java.lang.String setup)

      Constructor
      Parameters:
        `setup` - the definition of a sort rule

  - ### Method Detail

    - #### toStringInternal

          public java.lang.String toStringInternal()

      Gets the rule in internal format
      Returns:
        the rule in internal format

    - #### toString

          public java.lang.String toString()

      Prints the rule in human readable format
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a human readable formatted rule

    - #### setAttribute

          public void setAttribute(java.lang.String att)

      Set the name or index of the attribute to sort on
      Parameters:
        `att` - the name or index of tha attribute to sort on

    - #### getAttribute

          public java.lang.String getAttribute()

      Get the name or index of the attribute to sort on
      Returns:
        the name or index of the attribute to sort on

    - #### setDescending

          public void setDescending(boolean d)

      Set whether the sort should be descending rather than ascending
      Parameters:
        `d` - true for a descending sort

    - #### getDescending

          public boolean getDescending()

      Return true if the sort is descending
      Returns:
        true if the sort is descending

    - #### init

          public void init(Environment env,
                           Instances structure)

      Initialize the rule
      Parameters:
        `env` - the environment variables to use
        `structure` - the structure of the instances that the rule will opperate on

    - #### compare

          public int compare(weka.knowledgeflow.steps.Sorter.InstanceHolder o1,
                             weka.knowledgeflow.steps.Sorter.InstanceHolder o2)

      Compare two instances according to the rule
      Specified by:
        `compare` in interface `java.util.Comparator<weka.knowledgeflow.steps.Sorter.InstanceHolder>`
      Parameters:
        `o1` - the first instance
        `o2` - the second instance
      Returns:
        the result of the comparison