Define type sorter that will work without hanging