finally getting correct orders based on sort