sort_order is property of statmap
refactored purge and moved elementsort inside