The position will be a tuple of values:

            The QuerySet number inside of the QuerySetSequence.
            Whatever the normal value taken from the ordering property gives.
485268
def _get_position_from_instance(self, instance, ordering):
        
        # Get the QuerySet number of the current instance.
        qs_order = getattr(instance, '#')

        # Strip the '#' and call the standard _get_position_from_instance.
        result = super(SequenceCursorPagination, self)._get_position_from_instance(instance, ordering[1:])

        # Return a tuple of these two elements.
        return (qs_order, result)
328153
def seq(self, value):
        
        if value == self._defaults['seq'] and 'seq' in self._values:
            del self._values['seq']
        else:
            self._values['seq'] = value
681457
Index getIndexForColumns(OrderedIntHashSet set) {

        int   maxMatchCount = 0;
        Index selected      = null;

        if (set.isEmpty()) {
            return null;
        }

        for (int i = 0, count = indexList.length; i < count; i++) {
            Index currentindex = getIndex(i);
            int[] indexcols    = currentindex.getColumns();
            int   matchCount   = set.getOrderedMatchCount(indexcols);

            if (matchCount == 0) {
                continue;
            }

            if (matchCount == indexcols.length) {
                return currentindex;
            }

            if (matchCount > maxMatchCount) {
                maxMatchCount = matchCount;
                selected      = currentindex;
            }
        }

        if (selected != null) {
            return selected;
        }

        switch (tableType) {

            case TableBase.SYSTEM_SUBQUERY :
            case TableBase.SYSTEM_TABLE :
            case TableBase.VIEW_TABLE :
            case TableBase.TEMP_TABLE : {
                selected = createIndexForColumns(set.toArray());
            }
        }

        return selected;
    }
315761
def order(self, order):
    '''

    '''
    order = order if isinstance(order, Order) else Order(order)

    # ensure order gets attr values the same way the rest of the query does.
    order.object_getattr = self.object_getattr
    self.orders.append(order)
    return self
863921
private String getOrdinal(Integer value)
   {
      String result;
      int index = value.intValue();
      if (index >= ORDINAL.length)
      {
         result = "every " + index + "th";
      }
      else
      {
         result = ORDINAL[index];
      }
      return result;
   }
217486
def from_sequence(cls, seq):
        
        args = tuple(islice(seq, 4))
        if len(args) > 3:
            raise ValueError('When creating a Point from sequence, it '
                             'must not have more than 3 items.')
        return cls(*args)
977937
public int getSequenceNumber(Coordinate coord) {
		int minIndex = 0;
		double minDist = Double.MAX_VALUE;
		for (int i = 0; i < this.getPositions().length; i++) {
			if (this.getPositions()[i].distance(coord) < minDist) {
				minDist = this.getPositions()[i].distance(coord);
				minIndex = i;
			}
		}
		return minIndex;
	}
692111
def _order(self, value, is_reverse=None):
        

        def _dict_parser(dict_doc):
            """ dict ordered by:
            valueType_N -> key_N -> value_N
            """
            result = list()
            for key in dict_doc:
                data = self._order(dict_doc[key])
                res = (data[0], key, data[1])
                result.append(res)
            return tuple(result)

        def _list_parser(list_doc):
            """list will iter members to compare
            """
            result = list()
            for member in list_doc:
                result.append(self._order(member))
            return result

        # (TODO) include more data type
        if value is None or not isinstance(value, (dict,
                                                   list,
                                                   basestring,
                                                   bool,
                                                   float,
                                                   int)):
            # not support/sortable value type
            value = (0, None)

        elif isinstance(value, bool):
            value = (5, value)

        elif isinstance(value, (int, float)):
            value = (1, value)

        elif isinstance(value, basestring):
            value = (2, value)

        elif isinstance(value, dict):
            value = (3, _dict_parser(value))

        elif isinstance(value, list):
            if len(value) == 0:
                # [] less then None
                value = [(-1, [])]
            else:
                value = _list_parser(value)

            if is_reverse is not None:
                # list will firstly compare with other doc by it's smallest
                # or largest member
                value = max(value) if is_reverse else min(value)
            else:
                # if the smallest or largest member is a list
                # then compaer with it's sub-member in list index order
                value = (4, tuple(value))

        return value
171202
def r_num(obj):
    """"""
    if isinstance(obj, (list, tuple)):
        it = iter
    else:
        it = LinesIterator
    dataset = Dataset([Dataset.FLOAT])
    return dataset.load(it(obj))
602513
def _get_next_or_previous_by_order(self, is_next, **kwargs):
        
        lookup = self.with_respect_to()
        lookup["_order"] = self._order + (1 if is_next else -1)
        concrete_model = base_concrete_model(Orderable, self)
        try:
            queryset = concrete_model.objects.published
        except AttributeError:
            queryset = concrete_model.objects.filter
        try:
            return queryset(**kwargs).get(**lookup)
        except concrete_model.DoesNotExist:
            pass
897032
def queryset(self, request, queryset):
        
        if self.value():
            parent = Question.objects.get(slug=self.value())
            return Choice.objects.child_of(parent).order_by('-id')
        return queryset
533913
def _get_values(value):
    
    if (isinstance(value, tuple) and (2 <= len(value) <= 3) and
            all(hasattr(i, "__int__") for i in value)):
        # We use values[1] + 1 as stop value for (x)range to maintain
        # the behavior of using tuples as field `values`
        return range(*((int(value[0]), int(value[1]) + 1) +
                       tuple(int(v) for v in value[2:])))
    return value
708307
def count_by_value_impl(sequence):
    
    counter = collections.Counter()
    for e in sequence:
        counter[e] += 1
    return six.viewitems(counter)
210553
def paginate_queryset(self, queryset, request, view=None):
        
        result = super(MultipleModelLimitOffsetPagination, self).paginate_queryset(queryset, request, view)

        try:
            if self.max_count < self.count:
                self.max_count = self.count
        except AttributeError:
            self.max_count = self.count

        try:
            self.total += self.count
        except AttributeError:
            self.total = self.count

        return result
538444
def tuple_index(self, n):
        ''''''
        return n.args and n.args[-1].type == 'index' and general_type(n.args[-1].sequence.pseudo_type) == 'Tuple' and\
               n.args[-1].index.type == 'int' and\
               (n.args[-1].index.value == -1 or n.args[-1].index.value == len(n.args[-1].sequence.pseudo_type) - 2)
337762
def save_positions(post_data, queryset=None):
    
    if not queryset:
        queryset = ObjectPosition.objects.all()
    for key in post_data:
        if key.startswith('position-'):
            try:
                obj_id = int(key.replace('position-', ''))
            except ValueError:
                continue
            queryset.filter(pk=obj_id).update(position=post_data[key])
701522
def ne_(self, value):
        ''' 
        '''
        if isinstance(value, QueryField):
            return self.__cached_id != value.__cached_id
        return self.__comparator('$ne', value)