Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Java'da öntanımlı bir listeye göre sıralama yapmak
List<String> kurallar = Arrays.asList("ahmet", "veli", "mehmet");
List<String> sonuc = Arrays.asList("veli", "mehmet", "ahmet").stream()
  .sorted(Comparator.comparing(isim -> kurallar.indexOf(isim)))
assertThat(sonuc).isEqualTo(Arrays.asList("ahmet", "veli", "mehmet"));


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment