Java List Merge merge(List a, List b, Comparator comp)

Here you can find the source of merge(List a, List b, Comparator comp)

Description

merge

License

Mozilla Public License

Declaration

public static <T> void merge(List<T> a, List<T> b, Comparator<T> comp) 

Method Source Code


//package com.java2s;
/*/*ww w.j  a v a 2  s  . co m*/
 * Copyright (c) 2014 Tor C Bekkvik
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import java.util.*;

public class Main {
    public static <T> void merge(List<T> a, List<T> b, Comparator<T> comp) {
        b.addAll(a);
        b.sort(comp);
    }

    public static <T> List<T> sort(List<T> unsorted, Comparator<T> comp) {
        List<T> lst = new ArrayList<>(unsorted);
        lst.sort(comp);
        return lst;
    }
}

Related

  1. merge(List list)
  2. merge(List lst1, List lst2)
  3. merge(List stringList)
  4. merge(List text)
  5. merge(List a, List b)
  6. merge(List list)
  7. merge(List list, int split)
  8. merge(List list, List items)
  9. merge(String[] list)