I realize this is just debugging code, but it's probably better to share the implementation of the sorting.