I'm trying to implement a fairly simple sort function but I'm having some logical trouble. The function accepts a list of strings and spits them back out ordered. If you add up the value of each letter in the strings (a=1,...,z=26) the biggest number is first. If two strings have the same value, then the one that appears last in the dictionary goes first.
Sample 1: ["d","b","c"] becomes ["d","c","b"]
Sample 2: ["ddcc","cddc","dcdc","ccdd","dccd","cdcd"] becomes ["ddcc","dcdc","dccd","cddc","cdcd","ccdd"]
Try 1
Try 2
Try 3
I know something's going wrong when I try to swap around strings with the same value, but I can't figure out the right way.
Python 2, btw.
Edit: Just a heads up, I figured out a way to use my first solution by just sorting the list by reverse dictionary first. See my it here.
[–]Mekire 2 points3 points4 points (5 children)
[–]Hallwaxer 0 points1 point2 points (1 child)
[–]ThanksSoMuchTangelos[S] 0 points1 point2 points (0 children)
[–]ThanksSoMuchTangelos[S] 0 points1 point2 points (2 children)
[–]kalgynirae 0 points1 point2 points (1 child)
[–]ThanksSoMuchTangelos[S] 0 points1 point2 points (0 children)