fixed sorting error.

sorting incorrectly. don’t use dfs anymore for sorting. sped things up
a lot