[ 20, 3, 3, 5 ] // where this is the sorted array or supposed to be the sorted one
0// and this is the index which was supposed to be the entry point of num
these are the outputs I get, although I do not know why
yes, that is the sorted array you get, so something is not working as you want.
The sort method appears in the curriculum for the first time later, but if you want to use it, you need to learn how to use it.
Otherwise it would be best for you to use a different approach.