Python program:
import sys
def getMinimumSum ( arr , n ) :
    res = [ ]
    pos = [ ]
    neg = [ ]
    for i in range ( n ) :
        if ( arr [ i ] > 0 ) :
            pos . append ( i )
        elif ( arr [ i ] < 0 ) :
            neg . append ( i )
    if ( len ( pos ) >= 2 and len ( neg ) >= 2 ) :
        posMax = - sys . maxsize - 1
        posMaxIdx = - 1
        posMin = sys . maxsize
        posMinIdx = - 1
        negMax = - sys . maxsize - 1
        negMaxIdx = - 1
        negMin = sys . maxsize
        negMinIdx = - 1
        for i in range ( len ( pos ) ) :
            if ( arr [ pos [ i ] ] > posMax ) :
                posMaxIdx = pos [ i ]
                posMax = arr [ posMaxIdx ]
        for i in range ( len ( pos ) ) :
            if ( arr [ pos [ i ] ] < posMin and pos [ i ] != posMaxIdx ) :
                posMinIdx = pos [ i ]
                posMin = arr [ posMinIdx ]
        for i in range ( len ( neg ) ) :
            if ( abs ( arr [ neg [ i ] ] ) > negMax ) :
                negMaxIdx = neg [ i ]
                negMax = abs ( arr [ negMaxIdx ] )
        for i in range ( len ( neg ) ) :
            if ( abs ( arr [ neg [ i ] ] ) < negMin and neg [ i ] != negMaxIdx ) :
                negMinIdx = neg [ i ]
                negMin = abs ( arr [ negMinIdx ] )
        posVal = ( - 1.0 * posMax / posMin )
        negVal = ( - 1.0 * negMax / negMin )
        if ( posVal < negVal ) :
            res . append ( arr [ posMinIdx ] )
            res . append ( arr [ posMaxIdx ] )
            for i in range ( n ) :
                if ( i != posMinIdx and i != posMaxIdx ) :
                    res . append ( arr [ i ] )
        else :
            res . append ( arr [ negMinIdx ] )
            res . append ( arr [ negMaxIdx ] )
            for i in range ( n ) :
                if ( i != negMinIdx and i != negMaxIdx ) :
                    resal . append ( arr [ i ] )
        for i in range ( len ( res ) ) :
            print ( res [ i ] , end = " ▁ " )
        print ( )
    elif ( len ( pos ) >= 2 ) :
        posMax = - sys . maxsize
        posMaxIdx = - 1
        posMin = sys . maxsize
        posMinIdx = - 1
        for i in range ( len ( pos ) ) :
            if ( arr [ pos [ i ] ] > posMax ) :
                posMaxIdx = pos [ i ]
                posMax = arr [ posMaxIdx ]
        for i in range ( len ( pos ) ) :
            if ( arr [ pos [ i ] ] < posMin and pos [ i ] != posMaxIdx ) :
                posMinIdx = pos [ i ]
                posMin = arr [ posMinIdx ]
        res . append ( arr [ posMinIdx ] )
        res . append ( arr [ posMaxIdx ] )
        for i in range ( n ) :
            if ( i != posMinIdx and i != posMaxIdx ) :
                res . append ( arr [ i ] )
        for i in range ( len ( res ) ) :
            print ( res [ i ] , end = " ▁ " )
        print ( )
    elif ( len ( neg ) >= 2 ) :
        negMax = - sys . maxsize
        negMaxIdx = - 1
        negMin = sys . maxsize
        negMinIdx = - 1
        for i in range ( len ( neg ) ) :
            if ( abs ( arr [ neg [ i ] ] ) > negMax ) :
                negMaxIdx = neg [ i ]
                negMax = abs ( arr [ negMaxIdx ] )
        for i in range ( len ( neg ) ) :
            if ( abs ( arr [ neg [ i ] ] ) < negMin and neg [ i ] != negMaxIdx ) :
                negMinIdx = neg [ i ]
                negMin = abs ( arr [ negMinIdx ] )
        res . append ( arr [ negMinIdx ] )
        res . append ( arr [ negMaxIdx ] )
        for i in range ( n ) :
            if ( i != negMinIdx and i != negMaxIdx ) :
                res . append ( arr [ i ] )
        for i in range ( len ( res ) ) :
            print ( res [ i ] , end = " ▁ " )
        print ( )
    else :
        print ( " No ▁ swap ▁ required " )
if __name__ == " _ _ main _ _ " :
    arr = [ - 4 , 1 , 6 , - 3 , - 2 , - 1 ]
    n = len ( arr )
    getMinimumSum ( arr , n )

Index/key variables: i, negMaxIdx, negMinIdx, posMaxIdx, posMinIdx
Accumulator variables: neg, pos, res, resal
Iterator variables: i