Forget programming and pointers for a second, and think about a library. There are many shelves with lots of books. Each book is in certain coordinates. For example, the Tale of Two Cities may be located on Aisle P, Shelf 2, Slot 14; likewise, Jane Eyre can be on Aisle Q, Shelf 13, Slot 1. It is clear that you want books in the library to be well organized so that they can be easily found.
Now consider a librarian who is tasked with making sure that the books in the above coordinates are in the correct order. The librarian goes to each coordinate, looks at the names of books in these coordinates and determines which one should go first. In our case, the librarian would have noticed that since J comes before T, she needs to change books.
Your homework seems to be a C ++ version. The sort2 function gets two memory addresses (i.e., Book Locations), and it needs to make sure that the contents of the first location are correctly compared with the contents of the second location. (“Compares correctly,” as a rule, either “compares less” or “compares more than”, depending on whether you sort the ascending or descending.)
As for how sort2 is sort2 , this part is a bit confusing to explain, and my analogy doesn't work perfectly. The variables x and y are usually treated as data (for example, the contents of the book), but each of them also has an associated address (for example, where the book is located). If you type x , you request the contents of the variable; if you type &x , you request the appropriate memory address. Unlike books, computer memory is constantly changing (this is part of why computers are so useful, of course). Therefore, in this context, x and y better perceived as a named piece of memory, rather than names for actual data (for example, these are the names of the locations of the books, not the contents of the books). Therefore, when you call sort2(&x, &y) , the address operator explicitly indicates that you are working with locations x and y , not their data. After the call, the addresses x and y will not be changed, but their contents may have.
Hope this helps!