Fix alpha sorting and add order parameter into sort logic