Java - Sorting

java

https://docs.oracle.com/javase/tutorial/collections/interfaces/order.html
MergeSort
http://svn.python.org/projects/python/trunk/Objects/listsort.txt
https://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html
http://www.tutorialspoint.com/java/util/arrays_sort_int.htm
http://www.mkyong.com/java/java-object-sorting-example-comparable-and-comparator/
http://beginnersbook.com/2013/12/how-to-sort-arraylist-in-java/
http://beginnersbook.com/2013/12/java-arraylist-of-object-sort-example-comparable-and-comparator/
http://www.homeandlearn.co.uk/java/sorting_arrays.html
http://stackoverflow.com/questions/8938235/java-sort-an-array
http://stackoverflow.com/questions/2839137/how-to-use-comparator-in-java-to-sort
http://tutorials.jenkov.com/java-collections/sorting.html
http://stackoverflow.com/questions/80476/how-can-i-concatenate-two-arrays-in-java
http://javarevisited.blogspot.com/2013/02/combine-integer-and-string-array-java-example-tutorial.html
http://www.leveluplunch.com/java/examples/join-two-arrays/
http://www.rgagnon.com/javadetails/java-0636.html
http://www.avajava.com/tutorials/lessons/how-do-i-join-an-array-or-collection-of-strings-into-a-single-string.html
http://www.tutorialspoint.com/javaexamples/array_merge.htm
http://www.programcreek.com/2012/12/leetcode-merge-sorted-array-java/

http://www.java2novice.com/java-sorting-algorithms/merge-sort/
http://howtodoinjava.com/algorithm/merge-sort-java-example/
http://www.vogella.com/tutorials/JavaAlgorithmsMergesort/article.html
https://examples.javacodegeeks.com/core-java/mergesort-algorithm-in-java-code-example/
http://javahungry.blogspot.com/2013/06/java-sorting-program-code-merge-sort.html
http://codereview.stackexchange.com/questions/64711/merge-sort-an-integer-array

java.utils.Arrays:
sort
copyOf
fill

binarySearch: https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html

import java.util.Arrays;

private void mergeArray(int[] a, int[] b, int M) {
    for (int i = 0; i < a.length; i++) {
        b[M + i] = a[i];
    }
    Arrays.sort(b);
}

public static void main(String[] args) {
    int a[] = {2,4,5,7,9};
    int b[] = {2,4,5,7,9,0,0,0,0,0};
    mergeArray(a, b, 5);
}
static void mergeArray(int []a, int []b, int M ){
    Vector temp = new Vector();
    int i = 0;
    for (i = 0; i < a.length; i++) {
        temp.add(a[i]);
    }

    for (i = 0; i < b.length; i++) {
        if (!temp.contains(b[i])) {
            temp.add(b[i]);
        }
    }
    Collections.sort(temp);
    for (i = 0; i < temp.size(); i++) {
        b[i] = (int) temp.get(i);
    }        
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License