LPS-36645 use treeMap instead of HashMap to improve performance

Hey Shuyang, 

@csierra made this performance improvement and we wanted you to review it. 

Thank you!