Fix sorting of locals