Sorting involves arranging elements in a list in ascending or descending order. Bubble sort works by repeatedly swapping adjacent elements that are out of order. Selection sort works by repeatedly finding the minimum element and placing it at the beginning of the list. Both algorithms are demonstrated sorting the list (5 4 3 2 1) into ascending order (1 2 3 4 5).