def order(x, NoneIsLast=True, decreasing=False):
 omitNone = False
 if (NoneIsLast is None):
  NoneIsLast = True
  omitNone = True
 n = len(x)
 ix = range(n)
 if (None not in x):
  ix.sort(reverse=decreasing, key=(lambda j: x[j]))
 else:
  def key(i, x=x):
   elem = x[i]
   if (decreasing == NoneIsLast):
    return ((not (elem is None)), elem)
   else:
    return ((elem is None), elem)
  ix = range(n)
  ix.sort(key=key, reverse=decreasing)
 if omitNone:
  n = len(x)
  for i in range((n - 1), (-1), (-1)):
   if (x[ix[i]] is None):
    n -= 1
  return ix[:n]
 return ix

def order ( x , NoneIsLast = True , decreasing = False ) : omitNone = False if ( NoneIsLast is None ) : NoneIsLast = True omitNone = True n = len ( x ) ix = range ( n ) if ( None not in x ) : ix . sort ( reverse = decreasing , key = ( lambda j : x [ j ] ) ) else : def key ( i , x = x ) : elem = x [ i ] if ( decreasing == NoneIsLast ) : return ( ( not ( elem is None ) ) , elem ) else : return ( ( elem is None ) , elem ) ix = range ( n ) ix . sort ( key = key , reverse = decreasing ) if omitNone : n = len ( x ) for i in range ( ( n - 1 ) , ( - 1 ) , ( - 1 ) ) : if ( x [ ix [ i ] ] is None ) : n -= 1 return ix [ : n ] return ix
returns a list of indices in the order as when the given list is sorted .