Skip to content
Advertisement

Tag: sorting

Sort List of Strings by Characters In Java

I am trying to write a program to order a list of strings by most least frequent characters within the list. For example, if the list was [apple, orange, banana] the letter frequency within the list would be a – 5, n – 3, p – 2, e – 2, l- 1, o – 1, r – 1, g –

Sort List of string arrays by first element

I want to sort a list of string arrays by first element in each array element of same list, in reverse order, so 2, 1, 0 Here’s what i tried so far: The problem is that at sorted line i have an error highlighted, saying: “sorted(java.util.List, java.util.Comparator Answer Stream.sorted() takes a comparator (in addition to the overload that takes no

What is the role of the temp integer in the bubble sort code

Just wondering what is the role of array[j] = temp; This is the bubble sort sorting algorithm, new to Stack exchange so formatting might not be great Answer Imagine that you have a red ball in your left hand, and a blue ball your right. Now switch the balls … without throwing them in the air. How? Let me lend

Grouping and Double sorting List

I went through all the manuals out there and all SO questions but still unable to figure this out… I have a List (integer represents age): I need to: group the list by age, sort by group sizes (descending), sort by age (descending) So using the example above the result would have to be like this: What I tried: I

Sorting 3 Numbers from Least to Greatest

As part of a problem set I have to sort 3 numbers in ascending order. A simple enough task, but for some reason I’m not getting the expected result. Using arrays is not allowed. Below is my code; I’ve linked to my flowchart here. I cannot get the program to sort 3 numbers such as 5, 5, and -4. When

Apache Beam framework – sort in descending order

How do you sort in descending order using the Apache Beam framework? I managed to create a word count pipeline which sorts alphabetically the output by word, but did not figure out how to invert the sorting order. Here is the code: This code produces a list of words sorted alphabetically with its respective counts: Edit 1: After some debugging

How to set IgnoreCase on sort parameters from an http request in Spring Boot 1.4

I have a Spring Boot backend running and accepting HTTP requests. Example: http://www.myserver.com/devices/ I’m using Pageable to handle the requests and automatic Pagination and Sorting, so I’m able to use requests like: http://www.myserver.com/devices?sort=name,desc There is an issue however, that the sort if case sensitive, and thus the desired sorting result (case insensitive sorting) is not obtained. I know Pageable Sort

Heapsort Within a Given Range

I am trying to write a Heapsort method that only performs the sort within a given range passed into the method. The ranges low and high are passed in and these values correspond to values inside the heap, not indices of the heap. For example, the input array might be: 28 10 49 20 59 61 17 and if low

Advertisement