Sorting multiple conditions with null value

I have this code, which sorts an array list based on 3 variables result.sort(Comparator.comparing(FeConsumptionChannelDTO::getMeterName) .thenComparing(FeConsumptionChannelDTO::…

How do I write a Drake sort algorithm for sorting an array in Java? [closed]

I’m writing a Drake Sort Algorithm in java that will sort a collection of elements. The algorithm is supposed to work like this: An array for example: { -2, 4, 1, 4 } Get the max value of the array …

How to custom sort only specific results in Spring MongoDB?

Is it possible to sort only results that matches a condition in Spring Mongo? Let us say I have this data: Color Fruit Amount Orange Orange 23 Red Apple 4 Red Strawberry 66 Yellow Banana 2 I …

Compare elements of two arrays of Object

I am trying to build a generic merge method, part of a mergeSort algorithm but I am stuck on how to deal with the comparison. This is my code so far: public static Object[] merge(Object[] left, Object[…

Sort List of Strings arrays in Java

I’m trying to make a program that consists of an array of Strings . now I need to sort them in order ‘PJ’, ‘GHS’, ‘FJ’, ‘PAS’ and date. input : listOfStringArrays.add(new String[] { “200608&…

I need an algorithmic help to convert an input Array object to ArrayList<List> object? [closed]

I need an algorithmic help to convert an input array in Java having this content : {5,6,3,2,4,7} To this format : [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7]].

Best way to sort customerAddress in such a way that all primary address are at the top and others at the bottom

I am trying to sort the below list in such a way that primary address is at the top of the list followed by other address (p.getIsPrimary is a Boolean value and can be null). Is there any other way …

Java sort string array using Array.sort() like python’s sorted with key=lambda x:

I’m occasionally learning Java. As a person from python background, I’d like to know whether there exists something like sorted(iterable, key=function) of python in java. For exmaple, in python I can …

Java: Order a list of Objects based on Calendar date?

I have a list of Java Objects that all contain the following field: @JsonProperty @Column(name = “date”) private Calendar date; I want to order the list of objects based on the above field , the …

Array out of bound exception while doing topological sort

This code takes the no. of nodes in a graph and creates the graph with the number of nodes and then the user has to input the one-way edges between two vertices.(The formed Graph is a Directed Acyclic …