impl Dijkstra extention for QuickSort for duplicate keys