Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jakab922
Created July 1, 2013 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakab922/5904427 to your computer and use it in GitHub Desktop.
Save jakab922/5904427 to your computer and use it in GitHub Desktop.
preserve order unique
your_list
unique_d = {}
for i, el in enumerate(your_list):
unique_d.setdefault(el, i)
preserved_order_unique = map(lambda x: x[0], sorted([(key, val) for key, val in unique_d.iteritems()], lambda y: y[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment