I use the following code to create a histogram of grades.  Grades are provided as a List of strings such as "A-", "D+", "E" (don't ask), etc.  The +/- substitution hack is necessary to sort the grades in my desired order.

    f[s_String] := 
      If[StringLength@s == 1, s <> "b", 
       StringReplace[s, {"+" -> "a", "-" -> "c"}]];
    g[s_String] := StringReplace[s, {"a" -> "+", "b" -> "", "c" -> "-"}];
    Reverse@Sort@
      Tally@(f /@ {"C", "B-", "B", "B+", "B", "C-", "E", "B", "D", "D+", 
          "C-", "B", "C", "B-", "C+", "E", "B-", "B-", "C-", "A", "C", 
          "B-", "B", "C+", "B", "C", "B+", "C+", "D-", "C", "A", "E", "B",
           "B+", "C", "C", "D+", "D", "C", "C-", "C", "B", "D", "B", "B", 
          "E", "B", "W", "W"})
    BarChart[Last /@ %, ChartLabels -> g /@ First /@ %]

    (* {{"Wb", 2}, {"Eb", 4}, {"Dc", 1}, {"Db", 3}, {"Da", 2}, {"Cc", 
      4}, {"Cb", 9}, {"Ca", 3}, {"Bc", 5}, {"Bb", 11}, {"Ba", 3}, {"Ab", 
      2}} *)

[![enter image description here][1]][1]

I'm looking for a less hackish way to do this.  Any suggestions?


  [1]: https://i.sstatic.net/KZazd.jpg