Java Utililty Methods List Sort

List of utility methods to do List Sort

  1. HOME
  2. Java
  3. L
  4. List Sort

Description

The list of methods to do List Sort are organized into topic(s).

Method

List addAllSortNoDuplicates(List l1, List l2)
To merge and sort two lists of strings.
Set<String> set = new HashSet<String>();
List<String> list = new ArrayList<String>();
if (l1 != null && l2 != null) {
 set.addAll(l1);
 set.addAll(l2);
 list.addAll(set);
 if (!list.contains(null)) {
 Collections.sort(list);
...
void addSorted(final List list, final T element)
Adds a given new Comparable element to a given (already sorted) List at the right location so that the sorting order remains valid
list.add(getInsertIndex(list, element), element);
double[] calculateBox(List values, boolean copyAndSort)
0: Minimum regular value
1: Q1
2: Median
3: Q3
4: Maximum regular value
5: Mean
final double[] box = new double[6];
if (values != null && copyAndSort) {
 final List<Double> copy = new ArrayList<Double>(values);
 Collections.sort(copy);
 values = copy;
box[5] = calculateMean(values);
box[2] = calculateMedian(values, false);
...
double calculateQ1(List values, boolean copyAndSort)
calculate Q
double result = Double.NaN;
if (values != null) {
 if (copyAndSort) {
 final List<Double> copy = new ArrayList<Double>(values);
 Collections.sort(copy);
 values = copy;
 final int count = values.size();
...
List descendingSortByCreationTime(List tasks)
descending Sort By Creation Time
return tasks;
boolean equalUnsorted(List list1, List list2)
equal Unsorted
if (list1 == null || list2 == null) {
 return false;
for (String item : list2) {
 if (!list1.remove(item)) {
 return false;
if (list1.isEmpty()) {
 return true;
return false;
List extractRankedProducts(List unsortedProducts)
Extracts the products which occurred more than once in the unsorted list and sorts them based on their occurrence
final Map<String, Integer> occurencesMap = createOccurrenceMap(unsortedProducts);
Comparator<String> comparator = new Comparator<String>() {
 @Override
 public int compare(String o1, String o2) {
 Integer occurenceO1 = occurencesMap.get(o1);
 Integer occurenceO2 = occurencesMap.get(o2);
 int comparedOccurence = occurenceO2.compareTo(occurenceO1);
 return comparedOccurence;
...
String formatAsSortUniqCSVString(List s)
list of strings to one string comma separated.
e.g.
Map<String, String> u = new HashMap<String, String>();
for (Iterator<String> si = s.iterator(); si.hasNext();) {
 u.put(si.next().trim(), null);
List<String> rv = new ArrayList<String>();
rv.addAll(u.keySet());
rv.remove("");
Collections.sort(rv);
...
int getIndexForSortedInsert(final List listSorted, final String item)
Determines for a sorted list and an object, what index the string could be inserted.
if (listSorted == null || item == null) {
 return 0;
int low = 0;
int high = listSorted.size() - 1;
while (low <= high) {
 final int mid = (low + high) >>> 1;
 final String midVal = listSorted.get(mid);
...
List getNumberListSorted(String pagesStr)
get Number List Sorted
Set<Integer> set = getNumberSet(pagesStr);
List<Integer> list = new ArrayList<Integer>(set.size());
Iterator<Integer> it = set.iterator();
while (it.hasNext())
 list.add(it.next());
Collections.sort(list);
return list;


AltStyle によって変換されたページ (->オリジナル) /