Data Sorting

People have worked with lists and tables of data for centuries. Until the last few decades the only option was a hand written list. You can imagine that a hand written list of information is not easily rearranged!

Let’s say you wrote down a list of names of people to invite to a reunion. You wrote the list in order by first name. Then you realize that you would prefer it in order by last name. So now you will need to write the list all over again in the correct order.

If you had typed it in an application like Microsoft Word or Google Docs it would be somewhat easier. You could copy and paste to move each line to where it belongs. But that still is tedious and takes a lot of time.

There is a better easier way! Spreadsheets are great at sorting data.

Take a look at the follow in table of information about the fifty states of the USA. It looks like it is sorted by total square miles right now. But what if you wanted to see it in order by square miles of water? How about alphabetically by state name? How many ways could the data be arranged?

StateTotal RankTotal Miles^2Total Km^2Land RankLand Miles^2Land Km^2Land %Water RankWater Miles^2Water Km^2Water %
Alaska665,384.041,723,337570,640.951,477,95394,743.10245,384
Texas268,596.46695,662261,231.71676,5877,364.7519,075
California163,694.74423,967155,779.22403,4667,915.5220,501
Montana147,039.71380,831145,545.80376,9621,493.913,869
New Mexico121,590.30314,917121,298.15314,161292.15757
Arizona113,990.30295,234113,594.08294,207396.221,026
Nevada110,571.82286,380109,781.18284,332790.652,048
Colorado104,093.67269,601103,641.89268,431451.781,170
Wyoming97,813.01253,33597,093.14251,470719.871,864
Oregon98,378.54254,79995,988.01248,6082,390.536,191
Idaho83,568.95216,44382,643.12214,045925.832,398
Utah84,896.88219,88282,169.62212,8182,727.267,064
Kansas82,278.36213,10081,758.72211,754519.641,346
Minnesota86,935.83225,16379,626.74206,2327,309.0918,930
Nebraska77,347.81200,33076,824.17198,974523.641,356
South Dakota77,115.68199,72975,811.00196,3501,304.683,379
North Dakota70,698.32183,10869,000.80178,7111,697.524,397
Missouri69,706.99180,54068,741.52178,040965.472,501
Oklahoma69,898.87181,03768,594.92177,6601,303.953,377
Washington71,297.95184,66166,455.52172,1194,842.4312,542
Georgia59,425.15153,91057,513.49148,9591,911.664,951
Michigan96,713.51250,48756,538.90146,43540,174.61104,052
Iowa56,272.81145,74655,857.13144,669415.681,077
Illinois57,913.55149,99555,518.93143,7932,394.626,202
Wisconsin65,496.38169,63554,157.80140,26811,338.5729,367
Florida65,757.70170,31253,624.76138,88712,132.9431,424
Arkansas53,178.55137,73252,035.48134,7711,143.072,961
Alabama52,420.07135,76750,645.33131,1711,774.744,597
North Carolina53,819.16139,39148,617.91125,9205,201.2513,471
New York54,554.98141,29747,126.40122,0577,428.5819,240
Mississippi48,431.78125,43846,923.27121,5311,508.513,907
Pennsylvania46,054.34119,28044,742.70115,8831,311.643,397
Louisiana52,378.13135,65943,203.90111,8989,174.2323,761
Tennessee42,144.25109,15341,234.90106,798909.362,355
Ohio44,825.58116,09840,860.69105,8293,964.8910,269
Virginia42,774.93110,78739,490.09102,2793,284.848,508
Kentucky40,407.80104,65639,486.34102,269921.462,387
Indiana36,419.5594,32635,826.1192,789593.441,537
Maine35,379.7491,63330,842.9279,8834,536.8211,750
South Carolina32,020.4982,93330,060.7077,8571,959.795,076
West Virginia24,230.0462,75624,038.2162,259191.83497
Maryland12,405.9332,1319,707.2425,1422,698.696,990
Vermont9,616.3624,9069,216.6623,871399.711,035
New Hampshire9,349.1624,2148,952.6523,187396.511,027
Massachusetts10,554.3927,3367,800.0620,2022,754.337,134
New Jersey8,722.5822,5917,354.2219,0471,368.363,544
Hawaii10,931.7228,3136,422.6316,6354,509.0911,678
Connecticut5,543.4114,3574,842.3612,542701.061,816
Delaware2,488.726,4461,948.545,047540.181,399
Rhode Island1,544.894,0011,033.812,678511.071,324

Create a new file

Let’s copy the table into a new spreadsheet file.

  • Start from the main office.com screen and click on the Excel icon
  • Then click on “New blank workbook”
  • In the green bar along the top, click on the default file name and rename it to “sorting”
  • Then copy the data from the table of information about the states.
  • Paste it into your new worksheet.
  • Click on the little dialog that is usually on the right side towards the bottom and then choose “Paste Values”. This will remove the formatting from this web page and just pasted the plain values into the spreadsheet.
  • The easiest way to fix the column width is click on the upper left square of the grid to select all the rows and columns. Then double click the line between two columns and all the columns should autoresize to fit the information inside. If just the data is selected like it will be after you paste it in, it won’t work correctly. You need to select all the column as described.
  • If you like, you can give the sheet a better name by double clicking on the tab where it says “Sheet1” and giving it a more descriptive name.

If you need help, watch the following video.

Create new workbook for sorting

Now you are ready to sort the information.

  • Click the “Data” menu.
  • Select a cell somewhere within the table of data if you haven’t already.
  • Click the “Custom Sort” icon
Custom Sort
  • In the custom sort dialog, select “State” for the column.
  • Leave the default sort on “Cell Values”.
  • Also leave it on “Sort Ascending”.
  • Click OK

Now the list should be sorted by “State”!

Auto Fill

All the major spreadsheets, including Excel, make it very easy to auto fill values from example content that shows a pattern. We’ll use this capability to add ranking numbers to the Total Miles^2, Land Miles^2, and Water Miles^2.

  • Re-sort the list to be sorted by the Total Miles^2 in descending order.
  • Type a “1” in “B2” and “2” in “B3”. This establishes a pattern of incrementing by 1.
  • Select both cells
  • Now click the handle on the bottom right corner of the selected cells and drag the selection down to the bottom of the data.

Watch the follow video if you have any questions.

Auto Fill

That was really easy!

Now experiment with different patterns.

  • Enter a “5” in “B2” and a “10” in “B3”
  • Select both cells and then use the handle to auto fill down like you did before.
  • Note how it counts up by 5s!
  • Ok, now change it back to count up by 1s.

Continue Sorting and Ranking

  • Now sort and rank the “Total Land Miles^2” and “Total Water Miles^2.
  • If you want to try a quicker way, you can sort the table by having a cell selected in the column that you want to sort. Then clicking either the “Sort Ascending” or “Sort Descending” icons that are to the left of the “Custom Sort” icon.

Does your worksheet look like the following screenshot? If not, see if you can fix it.

Sorting Completed

Add Some Data

Now let’s add in the percent of land and water information. Don’t worry! It’s not hard.

  • Enter your first formula for the percent of land in “H2”.
  • Remember how to figure what percent a part is of the total? Just divide the part by the total. Or in other words “Total Land Miles^2 / Total Miles^2.
  • What are the cells that we need to use? Try “=F2/C2”.
  • Now copy the formula down to the bottom of the data.
  • Since it is showing is as a decimal we need to format the column as percentage.
  • Select the entire “H” column by clicking the H.
  • Go to the “Home” menu.
  • Now choose the correct format of “Percentage” from the drop down list.
Format Column
  • OK! Now do the same for the “Water %” column.
  • Enter the formula.
  • Copy/Drag it down.
  • Re-format it to “Percentage”.

Now you can sort the data by any column that you wish!!

Great job!