Class SortUtil

java.lang.Object
de.tomatengames.util.SortUtil

public class SortUtil extends Object
Provides Comparator functions.
Since:
1.0
  • Method Details

    • compareNumberPreserving

      public static int compareNumberPreserving(@Nullable String s1, @Nullable String s2)
      Compares the specified strings case-insensitive. If the strings contain numbers, the numbers are compared like numbers and not character-wise.

      Example:

      compare("Hello", "Test") => "Hello" < "Test"
      compare("Test1", "Test2") => "Test1" < "Test2"
      compare("Test11", "Test2") => "Test11" > "Test2"
      
      The string null is before all other strings.
      Parameters:
      s1 - The first string. May be null.
      s2 - The second string. May be null.
      Returns:
      -1 if s1<s2, 1 if s1>s2 or 0 if s1=s2.