From memory, I believe it goes like this. (don't quote me on it, though)
The person who comes first in the course will "take" the highest external mark as their internal mark, and the person who comes last will "take" the lowest external mark as their internal mark. Everyone else will get scaled accordingly, with raw ranking and mark difference as the main factors that contribute.
Keep in mind that the external (HSC) mark you get will not be affected. Whatever you get as your external is yours to keep.
Let's assume that there are four people in the class.
Student | Internal rank | internal mark | external mark
A | 1 | 97 | 82
B | 2 | 95 | 98
C | 3 | 82 | 96
D | 4 | 81 | 89
Now, we can see that student A is first in the course, so automatically, (s)he will be assigned the highest external mark as their internal mark.
We can also see that student D is last in the course, so automatically, (s)he will be assigned the lowest external mark as their internal mark.
Everyone else will be scaled accordingly.
So, it may end up looking like this:
Student | Internal | External | HSC mark
A | 98 | 82 | 90 (band 6)
B | 94 | 98 | 96 (band 6)
C | 86 | 96 | 91 (band 6)
D | 82 | 89 | 86 (band 5)
Once again, don't quote me on it because I'm still very unsure as to the process.