fix sorting of arrays
fix sorting of segments