Bubble Sort, Max, Min, Median and Average functions