Example usage for java.lang String CASE_INSENSITIVE_ORDER

List of usage examples for java.lang String CASE_INSENSITIVE_ORDER

Introduction

In this page you can find the example usage for java.lang String CASE_INSENSITIVE_ORDER.

Prototype

Comparator CASE_INSENSITIVE_ORDER

To view the source code for java.lang String CASE_INSENSITIVE_ORDER.

Click Source Link

Document

A Comparator that orders String objects as by compareToIgnoreCase .

Usage

From source file:Main.java

public static void main(String[] argv) {
    String[] rawStrings = { "B", "java2s.com", "b", "A", "a", "c", "C" };
    System.out.println(Arrays.toString(rawStrings));
    Arrays.sort(rawStrings, String.CASE_INSENSITIVE_ORDER);
    System.out.println(Arrays.toString(rawStrings));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String[] strArray = new String[] { "z", "a", "A" };
    List list = Arrays.asList(strArray);
    Collections.sort(list);// w  w  w. j av  a  2  s . co m

    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);

    Collections.sort(list, Collections.reverseOrder());

    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
    Collections.reverse(list);
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, String> oldMap = new HashMap<String, String>();
    oldMap.put("a", "1");
    oldMap.put("A", "2");

    Map<String, String> newMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    newMap.putAll(oldMap);/*  w ww . jav  a 2 s .co m*/
    String value = newMap.get("a");
    System.out.println(value);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String[] strArray = new String[] { "z", "a", "A" };
    List list = Arrays.asList(strArray);

    Collections.sort(list);/*  w ww.jav  a2s .co  m*/

    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);

    Collections.sort(list, Collections.reverseOrder());

    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
    Collections.reverse(list);
}

From source file:Main.java

public static void main(String[] args) {
    String[] teams = new String[5];
    teams[0] = "M";
    teams[1] = "c";
    teams[2] = "A";
    teams[3] = "l";
    teams[4] = "E";

    Arrays.sort(teams);/*from w w w .  ja  v a2s  .  c om*/
    System.out.println(Arrays.toString(teams));
    Arrays.sort(teams, String.CASE_INSENSITIVE_ORDER);
    System.out.println(Arrays.toString(teams));
}

From source file:MainClass.java

public static void main(String[] av) {

    String[] stringArray = new String[] { "c", "e", "a", "k" };

    ArrayList<String> list = new ArrayList<String>();
    for (String s : stringArray) {
        list.add(s);/*www .j  a  va 2s.  co  m*/
    }
    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);

    for (String s : list) {
        System.out.println(s);
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    String[] coins = { "Penny", "nickel", "dime", "Quarter", "dollar" };

    Set set = new TreeSet();
    for (int i = 0; i < coins.length; i++)
        set.add(coins[i]);/* w ww  . jav a2 s  . co m*/

    System.out.println(Collections.min(set));
    System.out.println(Collections.min(set, String.CASE_INSENSITIVE_ORDER));

    System.out.println("");

    System.out.println(Collections.max(set));
    System.out.println(Collections.max(set, String.CASE_INSENSITIVE_ORDER));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    int[] intArray = new int[] { 4, 1, 3, -23 };
    Arrays.sort(intArray);//from   w w w  .  jav  a2s.  c o m
    // [-23, 1, 3, 4]

    String[] strArray = new String[] { "z", "a", "C" };
    Arrays.sort(strArray);
    // [C, a, z]

    // Case-insensitive sort
    Arrays.sort(strArray, String.CASE_INSENSITIVE_ORDER);
    // [a, C, z]

    // Reverse-order sort
    Arrays.sort(strArray, Collections.reverseOrder());
    // [z, a, C]

    // Case-insensitive reverse-order sort
    Arrays.sort(strArray, String.CASE_INSENSITIVE_ORDER);
    Collections.reverse(Arrays.asList(strArray));
    // [z, C, a]
}

From source file:org.bigmouth.nvwa.utils.url.URLEncoder.java

public static void main(String[] args) {
    List<String> list = Lists.newArrayList();
    list.add("v=1.1");
    list.add("account=??001");
    list.add("action=getBalance");
    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
    ;//from   w  ww  .  ja  va  2s.  com
    String sign = DigestUtils.md5Hex(StringUtils.join(list, "&") + "&key=88868b9d511241c1ba48cfbf705e430f");
    System.out.println(sign);
}

From source file:TreeSetDemo.java

public static void main(String[] argv) {
    //+//w w  w  .  ja v  a  2 s  .  c  o m
    /*
     * A TreeSet keeps objects in sorted order. We use a Comparator
     * published by String for case-insensitive sorting order.
     */
    TreeSet tm = new TreeSet(String.CASE_INSENSITIVE_ORDER);
    tm.add("Gosling");
    tm.add("da Vinci");
    tm.add("van Gogh");
    tm.add("Java To Go");
    tm.add("Vanguard");
    tm.add("Darwin");
    tm.add("Darwin"); // TreeSet is Set, ignores duplicates.

    // Since it is sorted we can ask for various subsets
    System.out.println("Lowest (alphabetically) is " + tm.first());
    // Print how many elements are greater than "k"
    System.out.println(tm.tailSet("k").toArray().length + " elements higher than \"k\"");

    // Print the whole list in sorted order
    System.out.println("Sorted list:");
    java.util.Iterator t = tm.iterator();
    while (t.hasNext())
        System.out.println(t.next());
    //-
}