### Question:
LabelWriter { List<LabelResult> sortResults(Vector label, Vector discriminant, Collection<Integer> labelIndices, NodeIds nodeIds) throws ApplicationException { List<LabelResult> list = new ArrayList<LabelResult>(); for (int index : labelIndices) { long nodeId = nodeIds.getIdForIndex(index); Node node = nodeMediator.getNode(nodeId, organismId); Gene gene = getPreferredGene(node); list.add(new LabelResult(gene.getSymbol(), label.get(index), discriminant.get(index))); } Collections.sort(list); return list; } LabelWriter(String basePath, NodeMediator nodeMediator, long organismId); void write(String queryName, int fold, Vector label, Vector discriminant, Collection<Integer> labelIndices, NodeIds nodeIds);  }### Answer:
@Test public void testSort() throws Exception { File outfile = tempFolder.newFile("LabelWriterTest.txt"); writer = new LabelWriter(outfile.getPath(), mediator, organismId); Vector label = new DenseVector(new double[] { 0, 1, 0, 1 }); Vector discriminant = new DenseVector(new double[] { 2, 1, 1, 0 }); List<Integer> labelIndices = new ArrayList<Integer>(); labelIndices.add(3); labelIndices.add(1); labelIndices.add(2); labelIndices.add(0); NodeIds nodeIds = new NodeIds(organismId); nodeIds.setNodeIds(new long[] { 0, 1, 2, 3 }); List<LabelResult> results = writer.sortResults(label, discriminant, labelIndices, nodeIds); Assert.assertEquals("3", results.get(0).getName()); Assert.assertEquals("2", results.get(1).getName()); Assert.assertEquals("1", results.get(2).getName()); Assert.assertEquals("0", results.get(3).getName()); }