JSON reformat and sort