changed sort to asort to keep keys when reordering