Case - 3 :
else if ( neg . Count >= 2 ) { int negMax = Int32 . MinValue , negMaxIdx = - 1 ; int negMin = Int32 . MaxValue , negMinIdx = - 1 ; for ( int i = 0 ; i < neg . Count ; i ++ ) { if ( Math . Abs ( arr [ neg [ i ] ] ) > negMax ) { negMaxIdx = neg [ i ] ; negMax = Math . Abs ( arr [ negMaxIdx ] ) ; } } for ( int i = 0 ; i < neg . Count ; i ++ ) { if ( Math . Abs ( arr [ neg [ i ] ] ) < negMin && neg [ i ] != negMaxIdx ) { negMinIdx = neg [ i ] ; negMin = Math . Abs ( arr [ negMinIdx ] ) ; } } res . Add ( arr [ negMinIdx ] ) ; res . Add ( arr [ negMaxIdx ] ) ; for ( int i = 0 ; i < n ; i ++ ) if ( i != negMinIdx && i != negMaxIdx ) res . Add ( arr [ i ] ) ; for ( int i = 0 ; i < res . Count ; i ++ ) Console . WriteLine ( res [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; }