user
Given an example, generate an algorithm for sorting it.
Input: [3, 9, 5, 4, 7]
Output:
assistant
1. Set a variable i to 0.
2. Set a variable j to (i + 1).
3. If the item at index i is less than the item at index j, swap the two items.
4. Increase i by 1, and set j to (i + 1).
5. Repeat steps 3 and 4 until all items in the list have been compared and swapped if necessary.
6. Repeat the whole process until no more swaps are necessary.