List of usage examples for java.util Collections sort
@SuppressWarnings("unchecked") public static <T extends Comparable<? super T>> void sort(List<T> list)
From source file:Main.java
public static void main(String[] args) { List<String> list = Arrays.asList(args); Collections.sort(list); System.out.println(list);/*ww w .ja va 2s . c om*/ }
From source file:MainClass.java
public static void main(String args[]) throws Exception { List list = Arrays.asList("a", "c", "b"); Collections.sort(list); for (int i = 0, n = list.size(); i < n; i++) { if (i != 0) System.out.print(", "); System.out.print(list.get(i)); }/*from ww w .j a va2 s .c o m*/ System.out.println(); }
From source file:MainClass.java
public static void main(String[] a) { List list = new ArrayList(); list.add("A"); list.add("C"); list.add("B"); Collections.sort(list); System.out.println(list);//from ww w . j a v a 2s . c o m }
From source file:MainClass.java
public static void main(String args[]) { Vector v1 = new Vector(); v1.add("A");/*w ww . ja v a 2 s. c o m*/ v1.add("C"); v1.add("B"); Vector v2 = (Vector) v1.clone(); Collections.sort(v2); System.out.println(v1); System.out.println(v2); }
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); Collections.sort(list, String.CASE_INSENSITIVE_ORDER); Collections.sort(list, Collections.reverseOrder()); Collections.sort(list, String.CASE_INSENSITIVE_ORDER); Collections.reverse(list);//from w ww. j a v a 2 s .c om }
From source file:Main.java
public static void main(String[] args) { Vector v = new Vector(); v.add("1");/* w ww. j av a 2s . c o m*/ v.add("3"); v.add("5"); v.add("2"); v.add("4"); Collections.sort(v); for (int i = 0; i < v.size(); i++) System.out.println(v.get(i)); }
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); Collections.sort(list, String.CASE_INSENSITIVE_ORDER); Collections.sort(list, Collections.reverseOrder()); Collections.sort(list, String.CASE_INSENSITIVE_ORDER); Collections.reverse(list);/* www . ja va2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("1");// w w w . j a v a 2s . c o m v.add("3"); v.add("5"); v.add("2"); v.add("4"); Collections.sort(v); for (String str : v) { System.out.println(str); } }
From source file:Sort.java
public static void main(String args[]) { String[] strArray = new String[] { "Java", "Source", "And", "and", "Support", "java2s" }; List l = Arrays.asList(strArray); Collections.sort(l); System.out.println(l);// w ww .j a va 2s.c om }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("Z");// ww w . j av a 2 s .com v.add("B"); v.add("D"); v.add("E"); v.add("F"); Collections.sort(v); System.out.println(v); int index = Collections.binarySearch(v, "D"); System.out.println("Element found at : " + index); }