sorting routine moved to an abstract type