Fixed #4. Fixed self reference bug in sort.