Blurbs ansible coffeescript django dvcs erlang es6 hg javascript json lua mercurial peewee postgresql python scope sql sqlalchemy yaml

Sort list of tuples code python erlang

a = [(1, 2), (3, 4), (5, 6)]
sorted(a, cmp=lambda a, b: b[1] - a[1])
# [(5, 6), (3, 4), (1, 2)]

from operator import itemgetter
sorted(a, key=itemgetter(1), reverse=True)
# [(5, 6), (3, 4), (1, 2)]
A = [{1, 2}, {3, 4}, {5, 6}].
lists:sort(fun({_, A}, {_, B}) -> A >= B end, A).
% [{5,6},{3,4},{1,2}]

lists:reverse(lists:keysort(1, A)).
% [{5,6},{3,4},{1,2}]

Stuttering list code python erlang

a = [1, 2, 3, 4]
[i for i in a for _ in range(i)]
# [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]
A = [1, 2, 3, 4].
[I || I <- A, _ <- lists:seq(1, I)].
% [1,2,2,3,3,3,4,4,4,4]