Given an array of integers ,the cost to change an element is abs(newvalue — initialvalue) .Determine the minimum cost to sort the array either ascending or descending .
1<=n<=1e3 1<=arr[i]<=1e9
I couldnt find its solution after so much brainstorming can anyone help me out with its solution?