From the course: Mathematica 14 Essential Training

Unlock this course with a free trial

Join today to access over 26,700 courses taught by industry experts.

Sort and reorder lists

Sort and reorder lists

“

Lists of values store important information. You can gain further information by sorting lists, either in ascending or descending order, or reversing a list that you've already created. In this movie, I will show you how to sort your list, how to reverse its order, and also how to pad a list. So it is an exact length that might be required for some calculations. I have created a blank Mathematica notebook, and I will increase the zoom level from 100% to 150 to make things easier to read. So, at the bottom right corner, go from 100 to 150. I'll start by entering in my list data. So, that's hlist —that's the variable I'll use— equal (=). Then, in curly brackets, I'll type 1, 8, 7, 1, 2, 6, 3, 5 and 4 with each value separated by a comma. So, everything is good. Shift + Enter. And there we go. If I want to sort the list into descending order with the largest values at the start, I use the 'Sort' keyword. So, capital S, o, r, t, left square bracket. Oh excuse me, I need to assign it to a…

Contents