Yeah, right, lucky that the data happened to be like that. I really did not try very hard to sort, as the OP did not specify anything about that, I just included a sort on the keys to tidy up the output, and it turned out to be exactly the output sample provided in the OP.