finish sorting

finishes the sorting stuff.