CIPLigandRule implements ISequenceSubRule<ILigand> { private ILigand[] order(ILigand[] ligands) { ILigand[] newLigands = new ILigand[ligands.length]; System.arraycopy(ligands, 0, newLigands, 0, ligands.length); Arrays.sort(newLigands, numberRule); ILigand[] reverseLigands = new ILigand[newLigands.length]; for (int i = 0; i < newLigands.length; i++) { reverseLigands[(newLigands.length - 1) - i] = newLigands[i]; } return reverseLigands; }  @Override int compare(ILigand ligand1, ILigand ligand2);  }
@Test public void testOrder() throws Exception { IAtomContainer molecule = smiles.parseSmiles("CC(Br)([13C])[H]"); List<ILigand> ligands = new ArrayList<ILigand>(); VisitedAtoms visitedAtoms = new VisitedAtoms(); ligands.add(CIPTool.defineLigand(molecule, visitedAtoms, 1, 4)); ligands.add(CIPTool.defineLigand(molecule, visitedAtoms, 1, 3)); ligands.add(CIPTool.defineLigand(molecule, visitedAtoms, 1, 2)); ligands.add(CIPTool.defineLigand(molecule, visitedAtoms, 1, 0)); Collections.sort(ligands, new CIPLigandRule()); Assert.assertEquals("H", ligands.get(0).getLigandAtom().getSymbol()); Assert.assertEquals("C", ligands.get(1).getLigandAtom().getSymbol()); Assert.assertEquals("C", ligands.get(2).getLigandAtom().getSymbol()); Assert.assertEquals(13, ligands.get(2).getLigandAtom().getMassNumber().intValue()); Assert.assertEquals("Br", ligands.get(3).getLigandAtom().getSymbol()); }