I test a kernel setting live first and only write the file once it does what I want.
sudo sysctl -w vm.swappiness=10
echo 'vm.swappiness = 10' | sudo tee /etc/sysctl.d/99-local.conf
sudo sysctl --system
sysctl -w changes the value immediately and loses it at reboot. A .conf file in /etc/sysctl.d/ is read at boot, and sysctl --system loads every such file now so you can check the file is valid without rebooting. A higher number in the filename wins when two files set the same key. Read the current value with sysctl vm.swappiness.
Further reading: sysctl manual page