Added key indexed sort using queues