Skip to content

Instantly share code, notes, and snippets.

View romeech's full-sized avatar

Roman romeech

  • Absolute Engineering
  • Moscow
View GitHub Profile
@romeech
romeech / frequency_sort.py
Last active April 19, 2019 13:26
Once again about one-liners
from itertools import groupby
from functools import reduce
import time
def frequency_sort(items):
# {elem: first_occurrence_index}
occurrences = {}
for idx, val in enumerate(items):
if val not in occurrences: