Store the values having unique indexes
let values = [ ] ; for ( let p of s . values ( ) ) { values . push ( arr [ p . first ] [ p . second ] ) ; } values . sort ( function ( a , b ) { return a - b ; } ) ;