List<String> criteria = new ArrayList<String>();
// criteria.add("@doclength");
criteria.add("@modifieddate");
try {
DocumentSorter sorter = null;
// if (indexDoc.hasItem("DocumentSorter")) {
// sorter = indexDoc.getItemValue("DocumentSorter", DocumentSorter.class);
// sorter.setDatabase(db);
// System.out.println("Starting resort of " + sorter.getCount() + " documents");
// } else {
DocumentCollection coll = db.getAllDocuments();
sorter = new DocumentSorter(coll, criteria);
System.out.println("Starting resort of " + coll.getCount() + " documents");
// }
// System.out.println("SORTING...");
long startTime = System.nanoTime();
DocumentCollection sortedColl = sorter.sort();
long endTime = System.nanoTime();
System.out.println("Completed resort of " + sortedColl.getCount() + " in " + ((endTime - startTime) / 1000000) + " ms");
// int count = 0;
// for (Document doc : sortedColl) {
// // System.out.println(doc.getLastModifiedDate().getTime() + " " + doc.getNoteID());