Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. Comparator<Person> comp = new Comparator<Person>() {
  2.             // Opgave 1B:
  3.             // Comparatoren skal sorterer på heigth
  4.             @Override
  5.             public int compare(Person o1, Person o2) {
  6.                 double heigth1 = o1.heigth;
  7.                 double heigth2 = o2.heigth;
  8.                 if (heigth1 < heigth2) {
  9.                     return -1;
  10.                 } else if (heigth1 == heigth2) {
  11.                     return 0;
  12.                 } else {
  13.                     return 1;
  14.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement