Priority is assigned on the basis of atomic number thr higher the number the higher the priority.
You assign only the atoms directly attached to the stereocenter and if there are two or more groups the have the same atom, you address the next set of atoms that are directly attached to the duplicated atom. The atom next to the stereocenter that has attached groups which added atomic numbers are higher the priority is higher yhan the otehr atom with lower added attached groups to it. I find it helpful to draw the pictures in the 3-d format.