Would it be easier to call `faces.sort()` instead? I'm not sure I completely understand what's going on in this function. At the very least, add a JSDoc-style comment for this function explaining what its doing.