title: How to get rid of selection order for triangulation
body: <p>I am trying to create a triangulation (not sure if this is the right word) script? Basically what I am trying to achieve is create a polygon out of the selection of the locators (it must be 3 or more locators)</p>
  
  <p>While I am able to do so, I am having this order of selection problem.
  Eg. In my scene, there are 4 locators - loc1, loc2, loc3, loc4</p>
  
  <p>If I drag select from the loc1 upwards to loc4, instead of creating the polygon like in img01, it is created as shown in img02 ordered by the locator numbering sort of?
  Seems to me, it is sorting the selection based on its locator creation order, in which this is not what I am trying to do it</p>
  
  <p>Am I missing something?</p>
  
  <p>My code:</p>
  
  <pre><code>import maya.cmds as cmds
  
  pts = []
  
  cmds.select( cmds.listRelatives( type = 'locator', fullPath = True, allDescendents = True ) )
  cmds.select( cmds.listRelatives( parent = True, fullPath = True ) )
  sel = cmds.ls ( selection = True, type = 'transform' )
  
  if not sel:
      cmds.warning( "Please select a locator / No locators in selection " )
  
  
  for loc in sorted(sel):
      coords = cmds.xform (loc, query=True, worldSpace=True, pivots=True)[0:3]
      print coords
      pts.append(coords)
  
  cmds.polyCreateFacet(p = pts)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/XMTPJ.png" alt="img01">
  <img src="https://i.stack.imgur.com/Krr7h.png" alt="img02"></p>