Modified to sort by abolute values
function findMinSum ( arr , n ) { for ( let i = 1 ; i < n ; i ++ ) { if ( ! ( Math . abs ( arr [ i - 1 ] ) < Math . abs ( arr [ i ] ) ) ) { let temp = arr [ i - 1 ] ; arr [ i - 1 ] = arr [ i ] ; arr [ i ] = temp ; } } let min = Number . MAX_VALUE ; let x = 0 , y = 0 ; for ( let i = 1 ; i < n ; i ++ ) {