More efficient get_diff implementation

More efficient implementation of get_diff uses O(nlogn) algorithm by doing sort and merge rather than current O(n^2) algorithm