def square_sort(arr):
 a_list = [(- i) for i in arr if (i < 0)]
 if a_list:
  b_list = arr[:(len(a_list) - 1):(-1)]
  res = []
  while (a_list and b_list):
   if (a_list[(-1)] <= b_list[(-1)]):
    res.append((a_list.pop((-1)) ** 2))
   else:
    res.append((b_list.pop((-1)) ** 2))
  return (res + [(o ** 2) for o in (a_list[::(-1)] + b_list[::(-1)])])
 else:
  return [(o ** 2) for o in arr]

def square_sort ( arr ) : a_list = [ ( - i ) for i in arr if ( i < 0 ) ] if a_list : b_list = arr [ : ( len ( a_list ) - 1 ) : ( - 1 ) ] res = [ ] while ( a_list and b_list ) : if ( a_list [ ( - 1 ) ] <= b_list [ ( - 1 ) ] ) : res . append ( ( a_list . pop ( ( - 1 ) ) ** 2 ) ) else : res . append ( ( b_list . pop ( ( - 1 ) ) ** 2 ) ) return ( res + [ ( o ** 2 ) for o in ( a_list [ : : ( - 1 ) ] + b_list [ : : ( - 1 ) ] ) ] ) else : return [ ( o ** 2 ) for o in arr ]
from [-2 .