added sorted map utility function