I have followed this link and tried various probabilities to get the desired output
sorted([\'aa\', \'bb\', \'_dd\', \'BB\', \'AA\']) [\'AA\', \'BB\', \'_dd\'