Example usage for java.util List sort

List of usage examples for java.util List sort

Introduction

In this page you can find the example usage for java.util List sort.

Prototype

@SuppressWarnings({ "unchecked", "rawtypes" })
default void sort(Comparator<? super E> c) 

Source Link

Document

Sorts this list according to the order induced by the specified Comparator .

Usage

From source file:org.phoenicis.repository.types.LocalRepository.java

private List<CategoryDTO> fetchCategories(String typeId, File typeDirectory) {
    final File[] categoryDirectories = typeDirectory.listFiles();
    if (categoryDirectories == null) {
        return Collections.emptyList();
    }/*  w  w  w.ja va 2s. c o  m*/

    final List<CategoryDTO> results = new ArrayList<>();

    for (File categoryDirectory : categoryDirectories) {
        if (categoryDirectory.isDirectory() && !categoryDirectory.getName().startsWith(".")) {
            final File categoryJson = new File(categoryDirectory, "category.json");

            if (categoryJson.exists()) {
                final CategoryDTO jsonCategoryDTO = unSerializeCategory(categoryJson);
                final CategoryDTO.Builder categoryDTOBuilder = new CategoryDTO.Builder(jsonCategoryDTO);

                categoryDTOBuilder.withTypeId(typeId);

                if (StringUtils.isBlank(jsonCategoryDTO.getId())) {
                    if (!StringUtils.isBlank(jsonCategoryDTO.getName())) {
                        categoryDTOBuilder.withId(jsonCategoryDTO.getName().replaceAll(ID_REGEX, ""));
                    } else {
                        categoryDTOBuilder.withId(categoryDirectory.getName().replaceAll(ID_REGEX, ""));
                    }
                }

                final File categoryIconFile = new File(categoryDirectory, ICON_NAME);
                if (categoryIconFile.exists()) {
                    categoryDTOBuilder.withIcon(categoryIconFile.toURI());
                }

                categoryDTOBuilder.withApplications(fetchApplications(categoryDTOBuilder.getTypeId(),
                        categoryDTOBuilder.getId(), categoryDirectory));

                final CategoryDTO category = categoryDTOBuilder.build();
                results.add(category);
            }
        }
    }

    results.sort(Comparator.comparing(CategoryDTO::getName));
    return results;
}

From source file:eu.itesla_project.online.tools.PrintOnlineWorkflowSummaryTable.java

@Override
public void run(CommandLine line) throws Exception {
    OnlineConfig config = OnlineConfig.load();
    try (OnlineDb onlinedb = config.getOnlineDbFactoryClass().newInstance().create()) {
        List<String> workflowsIds = new ArrayList<String>();
        if (line.hasOption("workflow"))
            workflowsIds.add(line.getOptionValue("workflow"));
        else if (line.hasOption("workflows"))
            workflowsIds = Arrays.asList(line.getOptionValue("workflows").split(","));
        else if (line.hasOption("basecase")) {
            DateTime basecaseDate = DateTime.parse(line.getOptionValue("basecase"));
            workflowsIds = onlinedb.listWorkflows(basecaseDate).stream()
                    .map(OnlineWorkflowDetails::getWorkflowId).collect(Collectors.toList());
        } else if (line.hasOption("basecases-interval")) {
            Interval basecasesInterval = Interval.parse(line.getOptionValue("basecases-interval"));
            workflowsIds = onlinedb.listWorkflows(basecasesInterval).stream()
                    .map(OnlineWorkflowDetails::getWorkflowId).collect(Collectors.toList());
        } else {/*from  w  ww.  ja va 2 s . c  om*/
            System.out.println("You must specify workflow(s) or basecase(s)");
            return;
        }
        TableFormatterConfig tableFormatterConfig = TableFormatterConfig.load();
        try (TableFormatter formatter = PrintOnlineWorkflowUtils.createFormatter(tableFormatterConfig,
                (line.hasOption("output-file")) ? Paths.get(line.getOptionValue("output-file")) : null,
                TABLE_TITLE, new Column("WorkflowId"), new Column("Basecase"), new Column("Contingency"),
                new Column("State"), new Column("FailureStep"), new Column("FailureDescription"),
                new Column("ViolationType"), new Column("Violation"), new Column("ViolationStep"),
                new Column("Equipment"), new Column("Value"), new Column("Limit"))) {

            workflowsIds.sort((o1, o2) -> (o1.compareTo(o2)));
            System.out.println("Printing violations and failues of workflows " + workflowsIds);
            workflowsIds.forEach(workflowId -> {
                System.out.println("Printing violations and failures of workflow " + workflowId);
                Network basecase = onlinedb.getState(workflowId, 0);
                String basecaseId = basecase.getId();
                printPrecontingencyViolations(workflowId, basecaseId, onlinedb, formatter);
                printContingenciesViolations(workflowId, basecaseId, onlinedb, formatter);
            });
        }
    }
}

From source file:net.dv8tion.jda.core.entities.impl.ReceivedMessage.java

@Override
public String getContentStripped() {
    if (strippedContent != null)
        return strippedContent;
    synchronized (mutex) {
        if (strippedContent != null)
            return strippedContent;
        String tmp = getContentDisplay();
        //all the formatting keys to keep track of
        String[] keys = new String[] { "*", "_", "`", "~~" };

        //find all tokens (formatting strings described above)
        TreeSet<FormatToken> tokens = new TreeSet<>(Comparator.comparingInt(t -> t.start));
        for (String key : keys) {
            Matcher matcher = Pattern.compile(Pattern.quote(key)).matcher(tmp);
            while (matcher.find())
                tokens.add(new FormatToken(key, matcher.start()));
        }// w  ww.j a  v  a  2 s.  c o  m

        //iterate over all tokens, find all matching pairs, and add them to the list toRemove
        Deque<FormatToken> stack = new ArrayDeque<>();
        List<FormatToken> toRemove = new ArrayList<>();
        boolean inBlock = false;
        for (FormatToken token : tokens) {
            if (stack.isEmpty() || !stack.peek().format.equals(token.format)
                    || stack.peek().start + token.format.length() == token.start)

            {
                //we are at opening tag
                if (!inBlock) {
                    //we are outside of block -> handle normally
                    if (token.format.equals("`")) {
                        //block start... invalidate all previous tags
                        stack.clear();
                        inBlock = true;
                    }
                    stack.push(token);
                } else if (token.format.equals("`")) {
                    //we are inside of a block -> handle only block tag
                    stack.push(token);
                }
            } else if (!stack.isEmpty()) {
                //we found a matching close-tag
                toRemove.add(stack.pop());
                toRemove.add(token);
                if (token.format.equals("`") && stack.isEmpty())
                    //close tag closed the block
                    inBlock = false;
            }
        }

        //sort tags to remove by their start-index and iteratively build the remaining string
        toRemove.sort(Comparator.comparingInt(t -> t.start));
        StringBuilder out = new StringBuilder();
        int currIndex = 0;
        for (FormatToken formatToken : toRemove) {
            if (currIndex < formatToken.start)
                out.append(tmp.substring(currIndex, formatToken.start));
            currIndex = formatToken.start + formatToken.format.length();
        }
        if (currIndex < tmp.length())
            out.append(tmp.substring(currIndex));
        //return the stripped text, escape all remaining formatting characters (did not have matching
        // open/close before or were left/right of block
        return strippedContent = out.toString().replace("*", "\\*").replace("_", "\\_").replace("~", "\\~");
    }
}

From source file:com.thoughtworks.go.server.persistence.PipelineRepository.java

@SuppressWarnings({ "unchecked" })
public void updatePipelineTimeline(final PipelineTimeline pipelineTimeline,
        final List<PipelineTimelineEntry> tempEntriesForRollback) {
    getHibernateTemplate().execute(new HibernateCallback() {
        private static final int PIPELINE_NAME = 0;
        private static final int ID = 1;
        private static final int COUNTER = 2;
        private static final int MODIFIED_TIME = 3;
        private static final int FINGERPRINT = 4;
        private static final int NATURAL_ORDER = 5;
        private static final int REVISION = 6;
        private static final int FOLDER = 7;
        private static final int MOD_ID = 8;
        private static final int PMR_ID = 9;

        public Object doInHibernate(Session session) throws HibernateException {
            LOGGER.info("Start updating pipeline timeline");
            List<Object[]> matches = retrieveTimeline(session, pipelineTimeline);
            List<PipelineTimelineEntry> newPipelines = populateFrom(matches);
            addEntriesToPipelineTimeline(newPipelines, pipelineTimeline, tempEntriesForRollback);

            updateNaturalOrdering(session, newPipelines);
            LOGGER.info("Pipeline timeline updated");
            return null;
        }/*  www .j a  v  a 2s . c  o m*/

        private void updateNaturalOrdering(Session session, List<PipelineTimelineEntry> pipelines) {
            for (PipelineTimelineEntry pipeline : pipelines) {
                if (pipeline.hasBeenUpdated()) {
                    updateNaturalOrderForPipeline(session, pipeline.getId(), pipeline.naturalOrder());
                }
            }
        }

        private List<Object[]> loadTimeline(SQLQuery query) {
            long startedAt = System.currentTimeMillis();
            List<Object[]> matches = (List<Object[]>) query.list();
            long duration = System.currentTimeMillis() - startedAt;
            if (duration > 1000) {
                LOGGER.warn("updating in memory pipeline-timeline took: {} ms", duration);
            }
            return matches;
        }

        private List<Object[]> retrieveTimeline(Session session, PipelineTimeline pipelineTimeline) {
            SQLQuery query = session.createSQLQuery(queryExtensions.retrievePipelineTimeline());
            query.setLong(0, pipelineTimeline.maximumId());

            List<Object[]> matches = loadTimeline(query);
            sortTimeLineByPidAndPmrId(matches);
            return matches;
        }

        private void sortTimeLineByPidAndPmrId(List<Object[]> matches) {
            matches.sort((m1, m2) -> {
                long id1 = id(m1);
                long id2 = id(m2);
                if (id1 == id2) {
                    return (int) (pmrId(m1) - pmrId(m2));
                }
                return (int) (id1 - id2);
            });
        }

        private List<PipelineTimelineEntry> populateFrom(List<Object[]> matches) {
            ArrayList<PipelineTimelineEntry> newPipelines = new ArrayList<>();
            if (matches.isEmpty()) {
                return newPipelines;
            }

            Map<String, List<PipelineTimelineEntry.Revision>> revisions = new HashMap<>();

            String name = null;
            long curId = -1;
            Integer counter = null;
            double naturalOrder = 0.0;

            PipelineTimelineEntry entry = null;

            for (int i = 0; i < matches.size(); i++) {
                Object[] row = matches.get(i);
                long id = id(row);
                if (curId != id) {
                    name = pipelineName(row);
                    curId = id;
                    counter = counter(row);
                    revisions = new HashMap<>();
                    naturalOrder = naturalOrder(row);
                }

                String fingerprint = fingerprint(row);

                if (!revisions.containsKey(fingerprint)) {
                    revisions.put(fingerprint, new ArrayList<>());
                }
                revisions.get(fingerprint).add(rev(row));

                int nextI = i + 1;
                if (((nextI < matches.size() && id(matches.get(nextI)) != curId) || //new pipeline instance starts in next record, so capture this one
                nextI == matches.size())) {//this is the last record, so capture it
                    entry = new PipelineTimelineEntry(name, curId, counter, revisions, naturalOrder);
                    newPipelines.add(entry);
                }
            }
            return newPipelines;
        }

        private String folder(Object[] row) {
            return (String) row[FOLDER];
        }

        private PipelineTimelineEntry.Revision rev(Object[] row) {
            return new PipelineTimelineEntry.Revision(modifiedTime(row), stringRevision(row), folder(row),
                    modId(row));
        }

        private long pmrId(Object[] row) {
            return ((BigInteger) row[PMR_ID]).longValue();
        }

        private long modId(Object[] row) {
            return ((BigInteger) row[MOD_ID]).longValue();
        }

        private double naturalOrder(Object[] row) {
            return (Double) row[NATURAL_ORDER];
        }

        private Date modifiedTime(Object[] row) {
            return (Date) row[MODIFIED_TIME];
        }

        private String stringRevision(Object[] row) {
            return (String) row[REVISION];
        }

        private String fingerprint(Object[] row) {
            return String.valueOf(row[FINGERPRINT]);
        }

        private String pipelineName(Object[] row) {
            return (String) row[PIPELINE_NAME];
        }

        private int counter(Object[] row) {
            return row[COUNTER] == null ? -1 : ((BigInteger) row[COUNTER]).intValue();
        }

        private long id(Object[] first) {
            return ((BigInteger) first[ID]).longValue();
        }
    });
}

From source file:org.apache.pulsar.broker.admin.impl.PersistentTopicsBase.java

protected List<String> internalGetList() {
    validateAdminAccessForTenant(namespaceName.getTenant());

    // Validate that namespace exists, throws 404 if it doesn't exist
    try {/* w  ww.  jav  a2  s.c o  m*/
        policiesCache().get(path(POLICIES, namespaceName.toString()));
    } catch (KeeperException.NoNodeException e) {
        log.warn("[{}] Failed to get topic list {}: Namespace does not exist", clientAppId(), namespaceName);
        throw new RestException(Status.NOT_FOUND, "Namespace does not exist");
    } catch (Exception e) {
        log.error("[{}] Failed to get topic list {}", clientAppId(), namespaceName, e);
        throw new RestException(e);
    }

    List<String> topics = Lists.newArrayList();

    try {
        String path = String.format("/managed-ledgers/%s/%s", namespaceName.toString(), domain());
        for (String topic : managedLedgerListCache().get(path)) {
            if (domain().equals(TopicDomain.persistent.toString())) {
                topics.add(TopicName.get(domain(), namespaceName, decode(topic)).toString());
            }
        }
    } catch (KeeperException.NoNodeException e) {
        // NoNode means there are no topics in this domain for this namespace
    } catch (Exception e) {
        log.error("[{}] Failed to get topics list for namespace {}", clientAppId(), namespaceName, e);
        throw new RestException(e);
    }

    topics.sort(null);
    return topics;
}

From source file:io.stallion.dataAccess.db.SqlMigrationAction.java

public List<SqlMigration> getUserMigrations() {
    List<SqlMigration> migrations = list();
    File sqlDirectory = new File(settings().getTargetFolder() + "/sql");
    if (!sqlDirectory.isDirectory()) {
        Log.finer("Sql directory does not exist {0}", sqlDirectory.getAbsoluteFile());
        return migrations;
    }/*from   w  w  w  . ja v a2s .c o m*/
    Log.finer("Find sql files in {0}", sqlDirectory.getAbsolutePath());
    for (File file : sqlDirectory.listFiles()) {
        Log.finer("Scan file" + file.getAbsolutePath());
        if (!set("js", "sql").contains(FilenameUtils.getExtension(file.getAbsolutePath()))) {
            Log.finer("Extension is not .js or .sql {0}", file.getAbsolutePath());
            continue;
        }
        if (file.getName().startsWith(".") || file.getName().startsWith("#")) {
            Log.finer("File name starts with invalid character {0}", file.getName());
            continue;
        }
        if (!file.getName().contains("." + DB.instance().getDbImplementation().getName().toLowerCase() + ".")) {
            Log.finer("File name does not contain the name of the current database engine: \".{0}.\"",
                    DB.instance().getDbImplementation().getName().toLowerCase());
            continue;
        }
        if (!file.getName().contains("-")) {
            Log.finer("File name does not have version part {0}", file.getName());
            continue;
        }
        String versionString = StringUtils.stripStart(StringUtils.split(file.getName(), "-")[0], "0");
        if (!StringUtils.isNumeric(versionString)) {
            Log.finer("File name does not have numeric version part {0}", file.getName());
            continue;
        }
        Log.info("Load SQL file for migration: {0}", file.getName());

        migrations.add(new SqlMigration()
                .setVersionNumber(Integer.parseInt(StringUtils.stripStart(versionString, "0"))).setAppName("")
                .setFilename(file.getName()).setSource(FileUtils.readAllText(file)));
    }
    migrations.sort(new PropertyComparator<>("versionNumber"));
    return migrations;
}

From source file:pcgen.gui2.facade.Gui2InfoFactory.java

/**
 * @see pcgen.facade.core.InfoFactory#getHTMLInfo(TempBonusFacade)
 *//*from   ww  w .  j  a v  a 2  s  . c o m*/
@Override
public String getHTMLInfo(TempBonusFacade tempBonusFacade) {
    if (tempBonusFacade == null) {
        return EMPTY_STRING;
    }

    if (!(tempBonusFacade instanceof TempBonusFacadeImpl)) {
        final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
        infoText.appendTitleElement(tempBonusFacade.toString());
        return infoText.toString();
    }

    TempBonusFacadeImpl tempBonus = (TempBonusFacadeImpl) tempBonusFacade;
    CDOMObject originObj = tempBonus.getOriginObj();

    final HtmlInfoBuilder infoText;
    if (originObj instanceof Equipment) {
        infoText = getEquipmentHtmlInfo((Equipment) originObj);
    } else {
        infoText = new HtmlInfoBuilder();
        infoText.appendTitleElement(OutputNameFormatting.piString(originObj));
        infoText.append(" (").append(tempBonus.getOriginType()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (tempBonus.getTarget() != null) {
        String targetName = charDisplay.getName();
        if (tempBonus.getTarget() instanceof CDOMObject) {
            targetName = ((CDOMObject) tempBonus.getTarget()).getKeyName();
        }

        infoText.appendLineBreak();
        infoText.appendI18nElement("in_itmInfoLabelTextTarget", targetName); //$NON-NLS-1$

        StringBuilder bonusValues = new StringBuilder(100);
        Map<BonusObj, TempBonusInfo> bonusMap = pc.getTempBonusMap(originObj.getKeyName(), targetName);
        boolean first = true;
        List<BonusObj> bonusList = new ArrayList<>(bonusMap.keySet());
        bonusList.sort(new BonusComparator());
        for (BonusObj bonusObj : bonusList) {
            if (!first) {
                bonusValues.append(", "); //$NON-NLS-1$
            }
            first = false;
            String adj = ADJ_FMT.format(bonusObj.resolve(pc, "")); //$NON-NLS-1$
            bonusValues.append(adj + " " + bonusObj.getDescription()); //$NON-NLS-1$
        }
        if (bonusValues.length() > 0) {
            infoText.appendLineBreak();
            infoText.appendI18nElement("in_itmInfoLabelTextEffect", //$NON-NLS-1$
                    bonusValues.toString());
        }
    }

    if (originObj instanceof Spell) {
        Spell aSpell = (Spell) originObj;
        infoText.appendLineBreak();
        infoText.appendI18nElement("in_spellDuration", //$NON-NLS-1$
                aSpell.getListAsString(ListKey.DURATION));
        infoText.appendSpacer();
        infoText.appendI18nElement("in_spellRange", //$NON-NLS-1$
                aSpell.getListAsString(ListKey.RANGE));
        infoText.appendSpacer();
        infoText.appendI18nElement("in_spellTarget", //$NON-NLS-1$
                aSpell.getSafe(StringKey.TARGET_AREA));
    }

    String aString = originObj.getSafe(StringKey.TEMP_DESCRIPTION);
    if (StringUtils.isEmpty(aString) && originObj instanceof Spell) {
        Spell sp = (Spell) originObj;
        aString = DescriptionFormatting.piWrapDesc(sp, pc.getDescription(sp), false);
    } else if (StringUtils.isEmpty(aString) && originObj instanceof Ability) {
        Ability ab = (Ability) originObj;
        List<CNAbility> wrappedAbility = Collections
                .singletonList(CNAbilityFactory.getCNAbility(ab.getCDOMCategory(), Nature.NORMAL, ab));
        aString = DescriptionFormatting.piWrapDesc(ab, pc.getDescription(wrappedAbility), false);
    }
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        infoText.appendI18nElement("in_itmInfoLabelTextDesc", aString); //$NON-NLS-1$
    }

    aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, originObj.getPrerequisiteList(), false);
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        infoText.appendI18nElement("in_requirements", aString); //$NON-NLS-1$
    }

    aString = AllowUtilities.getAllowInfo(pc, originObj);
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        infoText.appendI18nElement("in_requirements", aString); //$NON-NLS-1$
    }

    infoText.appendLineBreak();
    infoText.appendI18nElement("in_itmInfoLabelTextSource", //$NON-NLS-1$
            SourceFormat.getFormattedString(originObj, Globals.getSourceDisplay(), true));

    return infoText.toString();
}

From source file:pcgen.gui2.facade.Gui2InfoFactory.java

/**
 * @see pcgen.facade.core.InfoFactory#getHTMLInfo(KitFacade)
 *//*from w  ww. j a  v a 2s  . c o  m*/
@Override
public String getHTMLInfo(KitFacade kitFacade) {
    if (kitFacade == null) {
        return EMPTY_STRING;
    }

    Kit kit = (Kit) kitFacade;

    final HtmlInfoBuilder infoText = new HtmlInfoBuilder();

    infoText.appendTitleElement(OutputNameFormatting.piString(kit));

    appendFacts(infoText, kit);

    String aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, kit.getPrerequisiteList(), false);
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        infoText.appendI18nElement("in_requirements", aString); //$NON-NLS-1$
    }

    aString = AllowUtilities.getAllowInfo(pc, kit);
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        infoText.appendI18nElement("in_requirements", aString); //$NON-NLS-1$
    }

    List<BaseKit> sortedObjects = new ArrayList<>();
    sortedObjects.addAll(kit.getSafeListFor(ListKey.KIT_TASKS));
    sortedObjects.sort(new ObjectTypeComparator());

    String lastObjectName = EMPTY_STRING;
    for (BaseKit bk : sortedObjects) {
        String objName = bk.getObjectName();
        if (!objName.equals(lastObjectName)) {
            if (!EMPTY_STRING.equals(lastObjectName)) {
                infoText.append("; ");
            } else {
                infoText.appendLineBreak();
            }
            infoText.append("  <b>" + objName + "</b>: ");
            lastObjectName = objName;
        } else {
            infoText.append(", ");
        }
        infoText.append(bk.toString());
    }

    BigDecimal totalCost = kit.getTotalCost(pc);
    if (totalCost != null) {
        infoText.appendLineBreak();
        infoText.appendI18nFormattedElement("in_kitInfo_TotalCost", //$NON-NLS-1$
                COST_FMT.format(totalCost), SettingsHandler.getGame().getCurrencyDisplay());
    }

    String desc = pc.getDescription(kit);
    if (!desc.isEmpty()) {
        infoText.appendLineBreak();
        infoText.appendI18nFormattedElement("in_InfoDescription", //$NON-NLS-1$
                DescriptionFormatting.piWrapDesc(kit, desc, false));
    }

    aString = kit.getSource();
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        infoText.appendI18nElement("in_sourceLabel", aString); //$NON-NLS-1$
    }
    //TODO ListKey.KIT_TASKS
    return infoText.toString();
}

From source file:org.silverpeas.web.jobdomain.control.JobDomainPeasSessionController.java

public List<UserDetail> getRemovedUsers() throws AdminException {
    final List<UserDetail> removedUsers = adminCtrl.getRemovedUsersInDomain(this.targetDomainId);
    removedUsers.sort(Comparator.comparing(UserDetail::getStateSaveDate).thenComparing(UserDetail::getLastName)
            .thenComparing(UserDetail::getFirstName).thenComparing(UserDetail::getId));
    return removedUsers;
}

From source file:pcgen.gui2.facade.EquipmentSetFacadeImpl.java

@Override
public boolean sortEquipment(EquipNode parentNode) {
    // Confirm our assumptions
    if (!(parentNode instanceof EquipNodeImpl) || !(parentNode.getBodyStructure() instanceof BodyStructure)
            || ((parentNode.getNodeType() != NodeType.EQUIPMENT)
                    && (parentNode.getNodeType() != NodeType.BODY_SLOT))) {
        return false;
    }/*w  w  w .  j  a v a  2  s. c o  m*/
    BodyStructure bodyStruct = (BodyStructure) parentNode.getBodyStructure();
    if (!bodyStruct.isHoldsAnyType()) {
        return false;
    }

    String pid = ((EquipNodeImpl) parentNode).idPath;
    boolean isBodyStructure = parentNode.getBodyStructure() instanceof BodyStructure;
    List<EquipNodeImpl> childList = new ArrayList<>();
    Map<String, EquipNodeImpl> origPathToNode = buildPathNodeMap();
    Map<String, EquipSet> origPathToEquipSet = buildPathEquipSetMap();
    for (Map.Entry<String, EquipNodeImpl> entry : origPathToNode.entrySet()) {
        final String origPath = entry.getKey();
        final EquipNodeImpl node = entry.getValue();
        EquipSet es = origPathToEquipSet.get(origPath);

        if (node.parent == parentNode) {
            childList.add(node);
            if (pid == null) {
                pid = es.getParentIdPath();
            }
        }
    }

    // Sort child list
    childList.sort(new EquipNameComparator());

    // Renumber paths
    // need to start from a unique id if only sorting some nodes at a level
    int id = isBodyStructure ? theCharacter.getNewChildId(pid) : 1;
    NumberFormat format = new DecimalFormat("00");
    for (EquipNodeImpl childNode : childList) {
        String origPath = childNode.idPath;
        String newPath = pid + '.' + format.format(id);
        nodeList.removeElement(childNode);
        EquipSet es = origPathToEquipSet.get(origPath);
        es.setIdPath(newPath);
        updateContainerPath(origPath, newPath, origPathToNode, origPathToEquipSet);
        childNode.setIdPath(newPath);
        nodeList.addElement(childNode);
        id++;
    }
    return true;
}