Perform sorting for BOM and NSE.