Allows sorting arbitrary items without modifying or copying them

@typedef {Object} itemDTO

@param {String|Object} item - original item
@param {Array} pathTokens - split path tokens. Extracted from `item` using `iteratee` and split using `splitRetain`
481701
function sortPaths(items/* , [iteratee, ] dirSeparator */) {
    assert(arguments.length >= 2, 'too few arguments');
    assert(arguments.length <= 3, 'too many arguments');

    var iteratee, dirSeparator;

    if (arguments.length === 2) {
        iteratee = identity;
        dirSeparator = arguments[1];
    }
    else {
        iteratee = arguments[1];
        dirSeparator = arguments[2];
    }

    assert(isArray(items), 'items is not an array');
    assert(isFunction(iteratee), 'iteratee is not a function');
    assert(typeof dirSeparator === 'string', 'dirSeparator is not a String');
    assert(dirSeparator.length === 1, 'dirSeparator must be a single character');

    //encapsulate into DTOs
    var itemDTOs = items.map(function (item) {
        var path = iteratee(item);

        assert(typeof path === 'string', 'item or iteratee(item) must be a String');

        return {
            item: item,
            pathTokens: splitRetain(path, dirSeparator)
        };
    });

    //sort DTOs
    itemDTOs.sort(createItemDTOComparator(dirSeparator));

    //decapsulate sorted DTOs and return
    return itemDTOs.map(function (itemDTO) {
        return itemDTO.item;
    });
}
579386
private function filter($items, $path, $type)
    {
        if (!$items) {
            return null;
        }

        return array_filter($items, function ($item) use ($path, $type) {
            $itemCopy = $item;

            // key into the value with the given path
            foreach ($path as $key) {
                $itemCopy = $itemCopy[$key];
            }

            if (strtolower($itemCopy) === strtolower($type)) {
                return $item;
            }
        });
    }
359233
function pathExpression (token, tokens) {
  const expression = []
  while (true) {
    if (!token) {
      break
    }
    if (token === ')') {
      tokens.unshift(token)
      break
    }
    if (includes('}]', token)) {
      throw new Error(`A fragment can't contain "${token}"`)
    }

    if (token === ',') {
      break
    }

    if (token === '[') {
      expression.push(escapedFragment(token, tokens))
    } else if (token === '(') {
      expression.push(pathExpressions(token, tokens))
    } else if (token === '{') {
      expression.push(customFragment(token, tokens))
    } else {
      expression.push(unescapedFragment(token, tokens))
    }
    token = tokens.shift()
  }
  return { _type: pathExpression.name, expression }
}
892421
function objPath(obj, path) {
  if (!path) {
    return obj;
  }
  path = path.split('.');
  let i = 0;
  while (obj && i < path.length) {
    obj = obj[path[i++]];
  }
  return obj;
}
205029
function Routes(opts, items) {
	var self = this;
	opts = opts || {};
	items = items || [];
	debug.assert(self).is('object');
	debug.assert(opts).is('object');
	debug.assert(items).is('array');

	opts = copy(opts);
	self.file = opts.file;
	self.items = copy(items);
	self.changed = opts.changed || false;

	debug.assert(self.items).is('array');

	// Make an object (hash map) as an index for searching targets faster (path + method)
	self.targets = {};
	load_targets(self);

	debug.assert(self.file).is('string');
	debug.assert(self.targets).is('object');
}
1060520
function(item) {
      var parts = item.displayName.split('.');
      for (var i = parts.length - 1; i > 0; i--) {
        var name = parts.slice(0, i).join('.');
        if (itemsByName[name]) {
          return itemsByName[name];
        }
      }
    }
237595
function todolist_items(node)
{

  var self = this;
  
  /* ATTRIBUTES */
  
  /* the main title of the item, this is placed as text */
  this.title = "";
  
  /* whether or not the checkbox has been clicked */
  this.complete = false;
  
  /* whether this item should be displayed */
  this.hide = false;
  
  /* tells if favorite is active, updates svg to show yellow one */
  this.favorite = false;
  
  /* passed oncomplete method fired when checkbox is clicked */
  this.onComplete = function(){};
  
  /* oassed ondelete method fired when trashcan is clicked */
  this.onDelete = function(){};
  
  /* FILTERS */
  
  /* simple filter that changed display css style based on `hide` */
  this.filters.isHidden = function(v)
  {
    return (v ? 'none' : 'inherit');
  }
  
  /* filter that returns color based on `complete` for the item background */
  this.filters.statusBackground = function(v)
  {
    /* sometimes checkbox returns value as string, this will be fixed later */
    v = (typeof v === 'string' ? (v === 'true') : v);
    return (v ? '#5a8451' : '#FFF');
  }
  
  /* filter that returns color based on `complete` for the text color */
  this.filters.statusColor = function(v)
  {
     /* sometimes checkbox returns value as string, this will be fixed later */
    v = (typeof v === 'string' ? (v === 'true') : v);
    return (v ? '#FFF' : '#888787');
  }
  
  /* helps with checking the input when the value changes, will not be needed when input update is done */
  this.filters.placecheck = function(v)
  {
    node.querySelector('input').checked = (typeof v === 'string' ? (v === 'true') : !!v);
    return v;
  }
  
  /* changes css class based on `favorite` property */
  this.filters.activeFav = function(v)
  {
    return (v ? 'active' : '');
  }
  
  /* simple filter that prepends a `-` to a string if it is not empty, use for classnames etc */
  this.filters.prependDash = function(v)
  {
    return (v.length !== 0 ? '-'+v : v);
  }
  
  /* EVENTS */
  
  /* fires when checkbox is clicked */
  this.onClickComplete = function(e)
  {
    /* assign checked value */
    self.complete = this.checked;
    
    /* fire passed oncomplete method */
    self.onComplete(self.complete);
  }
  
  /* fires if favorite was clicked */
  this.onClickFavorite = function(e)
  {
    self.favorite = !self.favorite;
  }
  
  /* fires passed ondelete when trashcan is clicked */
  this.onClickDelete = function(e)
  {
    self.onDelete(self.title);
  }
}
285872
function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition, includeJsDocComment) {
        if (includeJsDocComment === void 0) { includeJsDocComment = false; }
        var current = sourceFile;
        outer: while (true) {
            if (isToken(current)) {
                // exit early
                return current;
            }
            if (includeJsDocComment) {
                var jsDocChildren = ts.filter(current.getChildren(), ts.isJSDocNode);
                for (var _i = 0, jsDocChildren_1 = jsDocChildren; _i < jsDocChildren_1.length; _i++) {
                    var jsDocChild = jsDocChildren_1[_i];
                    var start = allowPositionInLeadingTrivia ? jsDocChild.getFullStart() : jsDocChild.getStart(sourceFile, includeJsDocComment);
                    if (start <= position) {
                        var end = jsDocChild.getEnd();
                        if (position < end || (position === end && jsDocChild.kind === 1 /* EndOfFileToken */)) {
                            current = jsDocChild;
                            continue outer;
                        }
                        else if (includeItemAtEndPosition && end === position) {
                            var previousToken = findPrecedingToken(position, sourceFile, jsDocChild);
                            if (previousToken && includeItemAtEndPosition(previousToken)) {
                                return previousToken;
                            }
                        }
                    }
                }
            }
            // find the child that contains 'position'
            for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) {
                var child = current.getChildAt(i);
                // all jsDocComment nodes were already visited
                if (ts.isJSDocNode(child)) {
                    continue;
                }
                var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment);
                if (start <= position) {
                    var end = child.getEnd();
                    if (position < end || (position === end && child.kind === 1 /* EndOfFileToken */)) {
                        current = child;
                        continue outer;
                    }
                    else if (includeItemAtEndPosition && end === position) {
                        var previousToken = findPrecedingToken(position, sourceFile, child);
                        if (previousToken && includeItemAtEndPosition(previousToken)) {
                            return previousToken;
                        }
                    }
                }
            }
            return current;
        }
    }
1130008
function (item, field) {
            var path = field.split("."), value = item;
            while (path.length && typeof(value) !== "undefined") {
                value = value[path.shift()];
            }
            return value;
        }
1196703
function dangle_routing(in_item){
	    if( in_item.level < max_depth ){
		in_item.brackets.push({id: in_item.id,
				       routing_node: true,
				       level: in_item.level + 1,
				       parent_id: in_item.id,
				       brackets: []
				      });
		dangle_routing(in_item.brackets[0]);
	    }
	    return in_item;
	}
542964
function (type, item) {
        switch(type) {
            case simpleTypes.undefined:
            case simpleTypes.null:
                return true;
            case simpleTypes.string:
                if (item.trim().length === 0) {
                    return true;
                }
                return false;
            case simpleTypes.object:
                return (Object.keys(item).length === 0);
            case simpleTypes.array:
                return (item.length === 0);
            default:
                return false;
        };
    }
222449
function (item) {
        let result = {};
        if (item === __private.local) {
            Object.keys(__private.local).forEach(function (e) {
                result = Object.assign(result, _getLocalItems(__private.local[e]));
            });
            return result;
        }
        switch (item.type) {
            case Type.STRING:
            case Type.NUMBER:
            case Type.BOOLEAN:
            case Type.UNDEFINED:
                result[item.key] = item.timestamp;
                break;
            case Type.ARRAY:
            case Type.OBJECT:
                item.value.forEach(function (e) {
                    result = Object.assign(result, _getLocalItems(e));
                });
                break;
            default:
                _logUnknownType(item.type);
        }
        return result;
    }
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);
        }
    }
664615
function convertItems(items)
                        {
                            if (!items || items.length <= 0)
                                return;

                            items.forEach(function (item) {
                                getPageIndex(item).then(
                                        function (pageIndex) {
                                            if (pageIndex != null)
                                                item.pageIndex = pageIndex;
                                            else
                                                delete item.pageIndex;
                                        },
                                        function (error) {
                                            log.error(
                                                    "cannot determine page index for outline item",
                                                    item, error);
                                            delete item.pageIndex;
                                        }
                                );
                                convertItems(item.items);
                            });
                        }
1329160
def tokenlist(item, sep, suppress=True):
    """"""
    if suppress:
        sep = sep.suppress()
    return item + ZeroOrMore(sep + item) + Optional(sep)
155758
function decendTreeByRoutedToken(node, value, routeToken) {
    var next = null;
    switch (value) {
        case Keys.keys:
        case Keys.integers:
        case Keys.ranges:
            next = node[value];
            if (!next) {
                next = node[value] = {};
            }
            break;
        default:
            break;
    }
    if (next && routeToken) {
        // matches the naming information on the node.
        next[Keys.named] = routeToken.named;
        next[Keys.name] = routeToken.name;
    }

    return next;
}
660976
function join(separator, itemList) {
    var result = "";
    for (var i = 0; i < itemList.length; i++) {
        if (i > 0) {
            result += separator;
        }
        result += itemList[i];
    }
    return result;
}