added test, fix for re-sorting