Added queue sorting