Fix sorting and loading of JSON