Make sorting functionality universal