If you are running Ubuntu (or any other Linux distro) and Windows in one computer most probably you are using Grub to support dual booting. Or may be two or more different Linux as I am running Debian and Ubuntu. During installation process most Linux distor install Grub which is short for GNU GRand Unified Bootloader and provides a user with choice to boot one of multiple operating systems installed on a computer or select a specific Linux kernel configuration available on a particular operating system.
First open and edit file /etc/default/grub by executing the following command.
howopensource@ubuntu:~$ sudo gedit /etc/default/grub
Then execute command to update Grub configuration. Command update-grub reads file /etc/default/grub and generates proper Grub configuration file.
howopensource@ubuntu:~$ sudo update-grub
To change boot order just execute the next command.
howopensource@ubuntu:~$ sudo grub-set-default 4
Pay attention that boot items are count from 0, not from 1. Also next time when you want to change boot order you just need to execute the last command – grub-set-default.
Hope this helps you to understand how Grub works. if you have problem with Grub you can read another article how to repair Grub from Ubuntu live CD.