Update the "getNewPosition" function. Add some checks to validate the after sorting value.
Merge branch 'master' into dev