You still need to create the middle datastructure ( [[k1,v1], [k2, v2]] ) but it is an improvement :)