Removed data copying for sorting.
Moved data sorting as others might need it and to avoid recomputation.