Order decorations according draw_order and size of selection.

        Highest draw_order will appear on top of the lowest values.

        If draw_order is equal,smaller selections are draw in top of
        bigger selections.
349180
def _order_decorations(self):
        
        def order_function(sel):
            end = sel.cursor.selectionEnd()
            start = sel.cursor.selectionStart()
            return sel.draw_order, -(end - start)

        self._decorations = sorted(self._decorations,
                                   key=order_function)
1061854
def sortByColumn(self, index, direction):
        
        if self.isPaged() and not self.isFullyLoaded():
            self.reorder(index, direction)
        else:
            super(XOrbTreeWidget, self).sortByColumn(index, direction)
1237372
def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
                   kind='quicksort', na_position='last',
                   sort_remaining=True, by=None):
        
        return self._frame.sort_index(axis=axis, level=level,
                                      ascending=ascending, inplace=inplace,
                                      kind=kind, na_position=na_position,
                                      sort_remaining=sort_remaining, by=by)
138373
def draw
      drawns = []
      @options[:include].each { |n| drawns << n } unless @options[:include].nil?
      count = @options[:include] ? @options[:pick] - @options[:include].count : @options[:pick]
      count.times { drawns << pick(drawns) }
      drawns
    end
753297
public void setOrdering(com.google.api.ads.admanager.axis.v201808.CreativeWrapperOrdering ordering) {
        this.ordering = ordering;
    }
825580
def set_sort_order(self, sort_order):
        

        if not isinstance(sort_order, SortOrder):
            raise DaftException("sort_order should be an instance of SortOrder.")

        self._sort_order = str(sort_order)
385293
def sort(self):
        
        if self.is_guaranteed_sorted:
            self.log(u"Already sorted, returning")
            return
        self.log(u"Sorting...")
        self.__fragments = sorted(self.__fragments)
        self.log(u"Sorting... done")
        self.log(u"Checking relative positions...")
        for i in range(len(self) - 1):
            current_interval = self[i].interval
            next_interval = self[i + 1].interval
            if current_interval.relative_position_of(next_interval) not in self.ALLOWED_POSITIONS:
                self.log(u"Found overlapping fragments:")
                self.log([u"  Index %d => %s", i, current_interval])
                self.log([u"  Index %d => %s", i + 1, next_interval])
                self.log_exc(u"The list contains two fragments overlapping in a forbidden way", None, True, ValueError)
        self.log(u"Checking relative positions... done")
        self.__sorted = True
793902
public static void orderBestPatterns(ResultPoint[] patterns) {

    // Find distances between pattern centers
    float zeroOneDistance = distance(patterns[0], patterns[1]);
    float oneTwoDistance = distance(patterns[1], patterns[2]);
    float zeroTwoDistance = distance(patterns[0], patterns[2]);

    ResultPoint pointA;
    ResultPoint pointB;
    ResultPoint pointC;
    // Assume one closest to other two is B; A and C will just be guesses at first
    if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
      pointB = patterns[0];
      pointA = patterns[1];
      pointC = patterns[2];
    } else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) {
      pointB = patterns[1];
      pointA = patterns[0];
      pointC = patterns[2];
    } else {
      pointB = patterns[2];
      pointA = patterns[0];
      pointC = patterns[1];
    }

    // Use cross product to figure out whether A and C are correct or flipped.
    // This asks whether BC x BA has a positive z component, which is the arrangement
    // we want for A, B, C. If it's negative, then we've got it flipped around and
    // should swap A and C.
    if (crossProductZ(pointA, pointB, pointC) < 0.0f) {
      ResultPoint temp = pointA;
      pointA = pointC;
      pointC = temp;
    }

    patterns[0] = pointA;
    patterns[1] = pointB;
    patterns[2] = pointC;
  }
1092106
function(node) {
        var zIndex = node._style.graphicZIndex;
        
        // Everything must have a zIndex. If none is specified,
        // this means the user *must* (hint: assumption) want this
        // node to succomb to drawing order. To enforce drawing order
        // over all indexing methods, we'll create a new z-index that's
        // greater than any currently in the indexer.
        if (zIndex == null) {
            zIndex = this.maxZIndex;
            node._style.graphicZIndex = zIndex; 
        } else if (zIndex > this.maxZIndex) {
            this.maxZIndex = zIndex;
        }
    }
371348
def sort_top_targets(self, top, orders):
        '''
        
        '''
        sorted_top = collections.defaultdict(OrderedDict)
        # pylint: disable=cell-var-from-loop
        for saltenv, targets in six.iteritems(top):
            sorted_targets = sorted(targets,
                    key=lambda target: orders[saltenv][target])
            for target in sorted_targets:
                sorted_top[saltenv][target] = targets[target]
        # pylint: enable=cell-var-from-loop
        return sorted_top
698238
def draw(self, mode, selection):
        
        if not self._linked:
            raise RuntimeError('Cannot draw program if code has not been set')
        # Init
        gl.check_error('Check before draw')
        mode = as_enum(mode)
        # Draw
        if len(selection) == 3:
            # Selection based on indices
            id_, gtype, count = selection
            if count:
                self._pre_draw()
                ibuf = self._parser.get_object(id_)
                ibuf.activate()
                gl.glDrawElements(mode, count, as_enum(gtype), None)
                ibuf.deactivate()
        else:
            # Selection based on start and count
            first, count = selection
            if count:
                self._pre_draw()
                gl.glDrawArrays(mode, first, count)
        # Wrap up
        gl.check_error('Check after draw')
        self._post_draw()
119814
public void sort ()
    {
        int size = size();

        if (DEBUG_SORT) {
            log.info("Sorting dirty item list", "size", size);
        }

        // if we've only got one item, we need to do no sorting
        if (size > 1) {
            // get items sorted by increasing origin x-coordinate
            _xitems.addAll(_items);
            _xitems.sort(ORIGIN_X_COMP);
            if (DEBUG_SORT) {
                log.info("Sorted by x-origin", "items", toString(_xitems));
            }

            // get items sorted by increasing origin y-coordinate
            _yitems.addAll(_items);
            _yitems.sort(ORIGIN_Y_COMP);
            if (DEBUG_SORT) {
                log.info("Sorted by y-origin", "items", toString(_yitems));
            }

            // sort the items according to the depth of the rear-most tile
            _ditems.addAll(_items);
            _ditems.sort(REAR_DEPTH_COMP);
            if (DEBUG_SORT) {
                log.info("Sorted by rear-depth", "items", toString(_ditems));
            }

            // now insertion sort the items from back to front into the render-sorted array
            _items.clear();
          POS_LOOP:
            for (int ii = 0; ii < size; ii++) {
                DirtyItem item = _ditems.get(ii);
                for (int rr = _items.size()-1; rr >= 0; rr--) {
                    DirtyItem pitem = _items.get(rr);
                    // if we render in front of this item, insert
                    // ourselves immediately following it
                    if (_rcomp.compare(item, pitem) > 0) {
                        _items.add(rr+1, item);
                        continue POS_LOOP;
                    }
                }
                // we don't render in front of anyone, so we go at the front of the list
                _items.add(0, item);
            }

            // clear out our temporary arrays
            _xitems.clear();
            _yitems.clear();
            _ditems.clear();
        }

        if (DEBUG_SORT) {
            log.info("Sorted for render", "items", toString(_items));
            for (int ii = 0, ll = _items.size()-1; ii < ll; ii++) {
                DirtyItem a = _items.get(ii);
                DirtyItem b = _items.get(ii+1);
                if (_rcomp.compare(a, b) > 0) {
                    log.warning("Invalid ordering", "a", a, "b", b);
                }
            }
        }
    }
278038
def __sort_up(self):
        """"""
        if self.__do_need_sort_up:
            self.__up_objects.sort(self.__up_cmp)
            self.__do_need_sort_up = False
443648
private void setSelectPositionY(int posY, int height) {

        m_markerStyle.setTop(posY, Unit.PX);
        m_markerStyle.setHeight(height, Unit.PX);

        m_overlayTopStyle.setHeight(posY, Unit.PX);
        m_overlayBottomStyle.setHeight(m_elementHeight - posY - height, Unit.PX);

        m_currentSelection.setTop(posY);
        m_currentSelection.setHeight(height);
    }
522720
def _calc_order(self, order):
        
        if order is not None and order != '':
            self.order = order.upper()
        else:
            shape = self.shape
            if len(shape) <= 2:
                self.order = 'M'
            else:
                depth = shape[-1]
                # TODO: need something better here than a guess!
                if depth == 1:
                    self.order = 'M'
                elif depth == 2:
                    self.order = 'AM'
                elif depth == 3:
                    self.order = 'RGB'
                elif depth == 4:
                    self.order = 'RGBA'
1153153
def draw_stacked_bar(self, nan_col_counts):
        
        for index, nan_values in enumerate(nan_col_counts):
            label, nan_col_counts = nan_values

            if index == 0:
                # first draw should be at zero
                bottom_chart = np.zeros(nan_col_counts.shape)

            # if features passed in then, label as such
            if self.classes_ is not None:
                label = self.classes_[index]

            color = self.colors[index]

            self.ax.barh(self.ind - self.width / 2, nan_col_counts, self.width,
                        color=color, label=label, left=bottom_chart)

            # keep track of counts to build on stacked
            bottom_chart = nan_col_counts
778430
def get_comparable_values_for_ordering(self):
        

        return (0 if self.position >= 0 else 1, int(self.position), str(self.name), str(self.description))