Applies sorting for Accessories list
332006
public function sortAccessoriesList()
    {
        $oxidRelationId = Registry::getConfig()->getRequestEscapedParameter('oxid');
        $selectedIdForSort = Registry::getConfig()->getRequestEscapedParameter('sortoxid');
        $sortDirection = Registry::getConfig()->getRequestEscapedParameter('direction');

        $accessoriesList = oxNew(ListModel::class);
        $accessoriesList->init("oxbase", "oxaccessoire2article");
        $sortQuery = "select * from  oxaccessoire2article where OXARTICLENID= " . DatabaseProvider::getDb()->quote($oxidRelationId) . " order by oxsort,oxid";
        $accessoriesList->selectString($sortQuery);


        $rebuildList = $this->rebuildAccessoriesSortIndexes($accessoriesList);

        if (($selectedPosition = array_search($selectedIdForSort, $rebuildList)) !== false) {
            $selectedSortRecord = $accessoriesList->offsetGet($rebuildList[$selectedPosition]);
            $currentPosition = $selectedSortRecord->oxaccessoire2article__oxsort->value;

            // get current selected row sort position

            if (($sortDirection == 'up' && $currentPosition > 0) || ($sortDirection == 'down' && $currentPosition < count($rebuildList) - 1)) {
                $newPosition = ($sortDirection == 'up') ? ($currentPosition - 1) : ($currentPosition + 1);

                // exchanging indexes
                $currentRecord = $accessoriesList->offsetGet($rebuildList[$currentPosition]);
                $newRecord = $accessoriesList->offsetGet($rebuildList[$newPosition]);

                $currentRecord->oxaccessoire2article__oxsort = new Field($newPosition);
                $newRecord->oxaccessoire2article__oxsort = new Field($currentPosition);
                $currentRecord->save();
                $newRecord->save();
            }
        }

        $outputQuery = $this->_getQuery();

        $normalQuery = 'select ' . $this->_getQueryCols() . $outputQuery;
        $countQuery = 'select count( * ) ' . $outputQuery;

        $this->_outputResponse($this->_getData($countQuery, $normalQuery));
    }
1228667
protected void sort(List<CmsTreeItem> items, SortParams sort) {

        int sortParam = -1;
        boolean ascending = true;
        switch (sort) {
            case tree:
                m_quickSearch.setFormValueAsString("");
                m_listView = false;
                updateContentTree();
                break;
            case title_asc:
                sortParam = 0;
                break;
            case title_desc:
                sortParam = 0;
                ascending = false;
                break;
            case path_asc:
                sortParam = 1;
                break;
            case path_desc:
                sortParam = 1;
                ascending = false;
                break;
            default:
                break;
        }
        if (sortParam != -1) {
            m_listView = true;
            items = getFilteredCategories(hasQuickFilter() ? m_quickSearch.getFormValueAsString() : null);
            Collections.sort(items, new CmsListItemDataComparator(sortParam, ascending));
            updateContentList(items);
        }
    }
394093
function sortBy(collection, evaluator) {
        var array = map(collection, function(item){return item})
        array.sort(function(a,b){
          var aValue = evaluator(a),
              bValue = evaluator(b)
          return aValue==bValue ? 0 : (aValue>bValue ? 1 : -1)
        })
        var sortedCollection = map(array, function(item){return item}, features.newCollection, features.append)
        return sortedCollection
      }
282327
def sort(base, items):
    
    return sorted(items, key=base.similarity, reverse=True)
188689
def _sortObjects(orderby='created', **kwargs):
    """"""
    o = []
    
    for m in kwargs.values():
        for l in iter(m):
            o.append(l)
    o = list(set(o))
    sortfunc = _sortByCreated if orderby == 'created' else _sortByModified
    if six.PY2:
        o.sort(sortfunc)
    else:
        o.sort(key=functools.cmp_to_key(sortfunc))

    return o
443034
def SortBy(*qs):
    """"""

    sort = []
    for q in qs:
        if q._path.endswith('.desc'):
            sort.append((q._path[:-5], DESCENDING))
        else:
            sort.append((q._path, ASCENDING))
    return sort
267724
private static void addOrder(Criteria c, String sort, String order, boolean ignoreCase) {
        if (ORDER_DESC.equals(order)) {
            c.addOrder(ignoreCase ? Order.desc(sort).ignoreCase() : Order.desc(sort));
        }
        else {
            c.addOrder(ignoreCase ? Order.asc(sort).ignoreCase() : Order.asc(sort));
        }
    }
1226286
def order_by(self, order_attribute):
        '''  '''
        to_return = []
        for f in sorted(self.items, key=lambda i: getattr(i, order_attribute)):
            to_return.append(f)
        return to_return
1130468
function(arr, comparator) {
			var lookup = [];
			return arr.filter(function(item) {
				var val = comparator ? comparator(item) : item;
				if (lookup.indexOf(val) < 0) {
					lookup.push(val);
					return true;
				}
			});
		}
991908
def sort(self, cmp=None, key=None, reverse=False):
        """"""
        if not key and self._keys:
            key = self.KeyValue
        super(CliTable, self).sort(cmp=cmp, key=key, reverse=reverse)
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
986169
def _sort(self):
        
        self.versions = OrderedDict(sorted(self.versions.items(), key=lambda v: v[0]))
655167
function(originalIndex, newIndex) {
      if(originalIndex < newIndex) {
         this.items.splice(newIndex+1,0, this.items[originalIndex]);
         this.items[originalIndex] = null;
      }
      else {
         this.items.splice(newIndex,0, this.items[originalIndex]);
         this.items[originalIndex+1] = null;
      }      
      this.items = inputEx.compactArray(this.items);
      
      this.listReorderedEvt.fire();
   }
990819
def apply_filter_list(func, obj):
    """"""
    if isinstance(obj, (list, tuple)):
        return [func(item) for item in obj]
    return func(obj)
939069
function(list, patterns) {

        var sorted = [];
        patterns.forEach(function(p) {
            sorted.push.apply(sorted, list.filter(function(file) {
                return p(file);
            }));
        });

        return sorted;

    }
46433
def selected_items
      ((m = marked_items).any? ? m : Array(current_item)).reject {|i| %w(. ..).include? i.name}
    end
51724
private function sortMiddleware()
    {
        $this->sorted = [];

        if (!$this->interposeFn) {
            foreach ($this->steps as $step) {
                foreach ($step as $fn) {
                    $this->sorted[] = $fn[0];
                }
            }
            return;
        }

        $ifn = $this->interposeFn;
        // Interpose the interposeFn into the handler stack.
        foreach ($this->steps as $stepName => $step) {
            foreach ($step as $fn) {
                $this->sorted[] = $ifn($stepName, $fn[1]);
                $this->sorted[] = $fn[0];
            }
        }
    }