Skip to content

Instantly share code, notes, and snippets.

@dyjjones
Created July 5, 2014 02:07
Show Gist options
  • Save dyjjones/73b4c967a12475fd4382 to your computer and use it in GitHub Desktop.
Save dyjjones/73b4c967a12475fd4382 to your computer and use it in GitHub Desktop.
unPythonic reverse
reverse = lambda s: ''.join([c for i,c in sorted(zip(range(len(s)), s), key=lambda c: -c[0])])
reverse('burrito') # otirrub
# Or do it in a single line!
(lambda s: ''.join([c for i,c in sorted(zip(range(len(s)), s), key=lambda c: -c[0])]))('burrito')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment