You can only extend the partition before the unallocated space. You'll need to use a 3rd party tool to move the partition you want to extend in front of the empty space. Be aware that if your computer loses power or reboots during that operation your system will likely stop working. I generally just use a live Linux usb and use gparted to move partitions