Dynamic loaded grid, sorting not working after moving column

I have a grid with server side paging. After loading the data, if i move , lets say column 2 to column 4 and sort the grid, my expectation is sorting should be done according to column 2 but sorting is done with respect to column 4. Is this scenario working in dynamically loaded grid? I am not sure if this is a framework bug or from my side. The grid definition is loaded from back-end.
If this is working, could anyone post a sample code for it?