GFG Sorting Comparable and Comparator interface
package com.company ; import java.awt. *; import java.util. *; import java.util. List ; class point { int x , y ; public point ( int x , int y ) { this . x = x ; this . y = y ; } } class myComparator implements Comparator < point >{ public int compare ( point p1 , point p2 ){ return p1 . x - p2 . x ; } } //Implementing Comparable interface //class point implements Comparable<point> { // int x, y; // public point(int x, int y) { // this.x = x; // this.y = y; // } // public int compareTo(point p){ // return x - p.x; // } //} //All even number comes first than all odd numbers class MyClass implements Comparator < Integer > { @Override public int compare ( Integer a , Integer b ) { return a % 2 - b % 2 ; } } public class Main { public static void main ( String [] args ) { // int[] array = {1,3,4,2,98,78}; //// Arrays.sort(array); // Arrays.sor...