import java.util.ArrayDeque; import java.util.Comparator; public class Fusion { private Comparator s; public Fusion(Comparator s) { this.s = s; } public void scinder(ArrayDeque first, ArrayDeque second) { second.clear(); int count = first.size() / 2; for (int i = 0; i < count; i++) { second.addFirst(first.pollLast()); } } public void fusionner(ArrayDeque first, ArrayDeque second) { for (T e : second) { first.addFirst(e); } } public void trier(ArrayDeque d) { switch (d.size()) { case 2: if (s.compare(d.getFirst(), d.getLast()) < 0) { d.addFirst(d.pollLast()); } break; default: ArrayDeque second = new ArrayDeque<>(); scinder(d, second); trier(d); trier(second); fusionner(d, second); } } }