add sort function to locals, closes #133