Advertisement
ssunlimited

Untitled

Jun 27th, 2022
979
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. public class SortList implements Comparator<Integer>{
  5.    public static List<Integer> list;
  6.    public static void main(String[] args) {
  7.       list = Arrays.asList(3, 2);
  8.       Collections.sort(list, new SortList());
  9.       for(int c : list) System.out.println(c + " "); // makes this arraylist of 3, 2 into 2, 3.
  10.    }
  11.    @Override
  12.    public int compare(Integer a, Integer b){
  13.       return a - b;
  14.    }
  15. }
Advertisement
RAW Paste Data Copied
Advertisement