Skip to content

Instantly share code, notes, and snippets.

Embed
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)))
  .collect(Collectors.toList());
assertThat(sonuc).isEqualTo(Arrays.asList("ahmet", "veli", "mehmet"));

Kaynak: https://stackoverflow.com/a/5245214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.