public Sorting build() { return new Sorting(specList); } }
public class prova { public static void main(String[] args) { List<Integer> a = Arrays.asList(1, 4, 3, 2, 0); Sorting s = new Sorting(new Comparator<Integer>() { @Override public int compare(Integer o1, Integer o2) { return o2-o1; } }); ArrayList<Integer> sorted = s.insertionSort(a); } }
for (Sorting.Spec spec : sorting.specs()) { sort(members, spec.name(), spec.ascending());
obj= new Sorting(); obj.start(); //calls the run method
Arrays.toString(new Sorting().sort(array to be sorted))
new Sorting().sortGains();
@Test public void getStorageCollectionsQueryAndSort() throws Exception { DBCollection collection = db.getCollection("testQuerySortCollection"); if (collection != null) { collection.drop(); } collection = db.createCollection("testQuerySortCollection", new BasicDBObject("count", 0)); // insert data records for the test setupPeopleData(collection); assertThat(collection.count()).isEqualTo(6); // going through DirectConnector will bypass phase where container sets up Pagination, Sorting, ReturnFields // so resourceParams are only relevant for 'q' parameter SimpleResourceParams resourceParams = new SimpleResourceParams(); resourceParams.put("q", "{country:{$ne:'FR'}}"); // This should return 4 items ordered by lastName descending and name ascending RequestContext requestContext = new RequestContext.Builder() .returnFields(new DefaultReturnFields("*(*)")) .sorting(new Sorting("-lastName,name")) .resourceParams(resourceParams).build(); ResourceState result = client.read(requestContext, "/testApp/" + BASEPATH + "/testQuerySortCollection"); String[] expectedAry = {"Helga", "Hans", "Jane", "John"}; assertThat(expectedAry).isEqualTo(getNames(result)); }
.sorting(new Sorting("lastName,-name")) .resourceParams(resourceParams).build(); ResourceState result = client.read(requestContext, "/testApp/" + BASEPATH + "/testSortCollection"); .sorting(new Sorting("lastName,-name")) .resourceParams(resourceParams) .pagination(new DefaultPagination(0, 2)).build(); .sorting(new Sorting("lastName,-name")) .resourceParams(resourceParams) .pagination(new DefaultPagination(2, 2)).build(); .sorting(new Sorting("lastName,-name")) .resourceParams(resourceParams) .pagination(new DefaultPagination(4, 2)).build();