dijkstra-matching and insertion-sort