Sort Worksheet problem (migration NAV 5 to NAV 2013)

Hi, I am dealing with a problem, because I want to sort worksheet by some columns

In NAV 5 it was created function with code:


and it was working. I want now to move it to NAV 2013, but I don’t have any idea how to do it.

I only know, that Range function have two parameters, but I have no idea how to sort it by colums. Can you please help me?