First of all, you should know that you can't use the dot(.) operator, after a primitive variable. So, if the variable 'i' is an 'int', you can't use anything like i.xxxx This is the problem of direference. Because of this, you have to use 'Integer', instead of 'int'.
You should be aware about the sorting mechanism. In this program, I used compareTo method to implement the business logic of Integer comparing. Please note that the comparation should be done only with the value of the variable 'i'. (Because the output should be 1,2,3,...). In your code, (and Alain's code) you are attempting to recursively compare the object 'v' with the same object 'v'. It is wrong. The actual thing we have to do is, comparing the value of the variable 'i' on current object, with the new 'v' object. Therefore the correct statement should be:
Following is the complete program for this:
Sorry for the inconvenience you had faced, when trying to copy this drag-and-drop program from the simulator