Helper function to sort scenes based on their index and view key.
332222
function compareScenes(one: NavigationScene, two: NavigationScene): number {
  if (one.index > two.index) {
    return 1;
  }
  if (one.index < two.index) {
    return -1;
  }

  return compareKey(one.key, two.key);
}
441909
public static void sort(double[] keys, int[] values, int start, int end) {
    quickSort(keys, values, start, end);
  }
1052947
def sorted(self):
        """"""
        for i in range(0, self.tabs.tabBar().count() - 1):
            if (self.tabs.tabBar().tabText(i) >
                    self.tabs.tabBar().tabText(i + 1)):
                return False
        return True
291272
function sortByFirst(valueArrays) {
  const firstValues = valueArrays[0];
  const indices = sortedIndices(firstValues);
  return valueArrays.map(function(values) {
    return indices.map(function(sortedIndex) {
      return values[sortedIndex];
    });
  });
}
1228691
function sortState (state) {
  return state.sort(function (a, b) {
    if (a === S_VIEWPORT) {
      return -1
    } else if (b === S_VIEWPORT) {
      return 1
    }
    return (a < b) ? -1 : 1
  })
}
1052729
private void sortLists(){
		//sort RGBformats
		//if native RGB24 is supported, put it first
		moveToFirstIfNative(RGBformats, V4L4JConstants.IMF_RGB24);
		
		//sort BGRformats
		//if native BGR24 is supported, put it first
		moveToFirstIfNative(BGRformats, V4L4JConstants.IMF_BGR24);
		
		//sort YUV420formats
		//if native YUV420 is supported, put it first
		moveToFirstIfNative(YUV420formats, V4L4JConstants.IMF_YUV420);
		
		//sort YVU420formats
		//if native YVU420 is supported, put it first
		moveToFirstIfNative(YVU420formats, V4L4JConstants.IMF_YVU420);
		
		//sort JPEGformats
		//put native formats first and libvideo converted ones next
		moveNativeFirst(JPEGformats);
		//if native RGB32 is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_RGB32);
		//if native RGB24 is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_RGB24);
		//if native UYVY is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_UYVY);
		//if native YUYV is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_YUYV);
		//if native YUV420P is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_YUV420);
		//if native MJPEG is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_MJPEG);
		//if native JPEG is supported, put it first
		moveToFirstIfNative(JPEGformats, V4L4JConstants.IMF_JPEG);
	}
406639
def dimension_sort(odict, kdims, vdims, key_index):
    
    sortkws = {}
    ndims = len(kdims)
    dimensions = kdims+vdims
    indexes = [(dimensions[i], int(i not in range(ndims)),
                    i if i in range(ndims) else i-ndims)
                for i in key_index]
    cached_values = {d.name: [None]+list(d.values) for d in dimensions}

    if len(set(key_index)) != len(key_index):
        raise ValueError("Cannot sort on duplicated dimensions")
    else:
       sortkws['key'] = lambda x: tuple(cached_values[dim.name].index(x[t][d])
                                        if dim.values else x[t][d]
                                        for i, (dim, t, d) in enumerate(indexes))
    if sys.version_info.major == 3:
        return python2sort(odict.items(), **sortkws)
    else:
        return sorted(odict.items(), **sortkws)
1157515
protected void sortIndexMap() {
        for (List<Doc> docs : indexmap.values()) {
            Collections.sort(docs, configuration.utils.makeComparatorForIndexUse());
        }
    }
162010
def sort_key(x):
    
    name, (r, u) = x
    return - len(u) + u.count('}') * 100
1174140
def sort(self):
        """"""
        super(JSSObjectList, self).sort(key=lambda k: k.id)
123960
def sort(self, values):
        """"""
        for level in self:
            for wire1, wire2 in level:
                if values[wire1] > values[wire2]:
                    values[wire1], values[wire2] = values[wire2], values[wire1]
840433
function forFade(props) {
  const { layout, position, scene } = props;

  if (!layout.isMeasured) {
    return forInitial(props);
  }
  const interpolate = getSceneIndicesForInterpolationInputRange(props);

  if (!interpolate) return { opacity: 0 };

  const { first, last } = interpolate;
  const index = scene.index;
  const opacity = position.interpolate({
    inputRange: [first, index, last],
    outputRange: [0, 1, 1],
  });

  return {
    opacity,
  };
}
63772
def asindices(hdr, spec):
    """"""

    flds = list(map(text_type, hdr))
    indices = list()
    if not isinstance(spec, (list, tuple)):
        spec = (spec,)
    for s in spec:
        # spec could be a field index (takes priority)
        if isinstance(s, int) and s < len(hdr):
            indices.append(s)  # index fields from 0
        # spec could be a field
        elif s in flds:
            indices.append(flds.index(s))
        else:
            raise FieldSelectionError(s)
    return indices
786990
def _sorted_keys_items(dobj):
    """"""
    keys = sorted(dobj.keys())
    for key in keys:
        yield key, dobj[key]
545242
def _sort(self):
        """"""
        self.__dict__['_z_ordered_sprites'] = sorted(self.sprites, key=lambda sprite:sprite.z_order)
1170818
def sort_items(items):
    """"""

    sorted_items = {}
    for item in items:
        category = lookup(item, 'itemCategory', 'categoryCode')
        if sorted_items.get(category) is None:
            sorted_items[category] = []
        sorted_items[category].append(item)

    return sorted_items
600613
def sort_menus(c):
        
        for name in c.items:
            if not c.sorted[name]:
                c.items[name].sort(key=lambda x: x.weight)
                c.sorted[name] = True