Unexpected behavior in Excel when sorting

  • #1
DaveC426913
Gold Member
22,497
6,168
TL;DR Summary
When I try to sort a spreadsheet, it ignores the first row (not a header.)
I'm trying to sort this sheet in Excel. I want to sort it on Column D.

1698778735967.png


I select the entire page by clicking the black arrow in the upper left corner:

1698778755418.png


Now I Data > Sort which brings up a dialogue where I specify the column I want to sort by :

1698778780227.png


(I can already tell there may be a problem - the first row has become deselected. This was not my doing. It happens every time):

1698778792033.png


An indeed, the sheet is sorted on column D, except the first row:

1698778811534.png


It doesn't matter how many times I do this - it's not a slip of the thumb - it always happens on this sheet. (And I have encountered this before, so it's not an artefact of this sheet only).

It's not a matter of data type of something life that. It happens on any other column I try to sort on:This is sorting on column A:

1698778859779.png


This is sorting on column F:

1698778872229.png


The only thing that worked was to cut and paste the row from the top to the bottom:

1698778913531.png


And now it sorts OK:

1698778939998.png
What am I doing wrong?
 
Computer science news on Phys.org
  • #2
[ UPDATE ]
Man there is nothing so effective for trouble-shooting as writing up the problem unambiguously in preparation for asking for help... :sorry:

When I went to update the veeery last screenshot, I saw this:
1698779437151.png
 
  • Like
  • Haha
Likes jrmichler, berkeman, jedishrfu and 4 others
  • #3
Is that why your first post has all strikeout text?
 
  • #4
jedishrfu said:
Is that why your first post has all strikeout text?
Yes. Save readers the time of reading through it all, only to discover I'd found the answer.

And I figured, since I'd already made the entire post, deleting it would only deprive some future readers in the same boat from reaping the benefit of my trials and tribulations.
 
  • Like
Likes jedishrfu, Baluncore and berkeman
  • #5
DaveC426913 said:
Man there is nothing so effective for trouble-shooting as writing up the problem unambiguously in preparation for asking for help...
Also for solving engineering problems....
 
  • #6
Probably the most important advantage of a forum like PF, is that the OP needs to work out what question to ask. After reading threads like this, we all become humbler.

“The only interesting answers are those which destroy the question”. —Susan Sontag
 
  • Like
Likes DaveC426913
  • #7
Dave, I also had to track this down one time. Obvious once you know about the option but MS Office software has SO many options that it's hard to keep track of them all.
 
  • #8
phinds said:
Dave, I also had to track this down one time. Obvious once you know about the option but MS Office software has SO many options that it's hard to keep track of them all.
Indeed. The gotcha in this case was that it the first row's behavior hinted at being a header, but the only way to define a row to behave as a header is to "freeze" it. Which of course, I did not do.

Knowing that's how Excel "handles" headers, one would not think to go looking for an option on a dialogue that said, effectively "Don't become a header, just pretend to act like one - for the moment - and then go back to being a regular row, like nothing ever happened." :mad:
 
  • Informative
  • Like
Likes phinds and Bystander

1. Why is Excel sorting my data in a different order than I intended?

Excel may be using a different sorting algorithm than the one you intended, or there may be hidden characters or spaces in your data that are affecting the sorting. Make sure to check your data for any inconsistencies or hidden characters before sorting.

2. How do I fix Excel from sorting my data by the wrong column?

You may have accidentally selected the wrong column or range of cells when sorting. Make sure to double check your selection before sorting. Additionally, you can use the "Sort by" option to specify which column to sort by.

3. Why is Excel not sorting my data at all?

There may be a few reasons for this. First, make sure that you have selected the entire range of data you want to sort. Also, check that you have specified which column to sort by. If your data includes empty cells, Excel may not be able to sort properly. In this case, you can try using the "Sort by" option to ignore empty cells.

4. How can I change the default sorting order in Excel?

The default sorting order in Excel is based on your regional settings. To change it, go to File > Options > Advanced, and under "General", you can change the "When calculating this workbook" option to "Use system separators". This will use the sorting order set in your operating system's regional settings.

5. Can I sort by multiple columns in Excel?

Yes, you can sort by multiple columns in Excel. Simply select the columns you want to sort by in the "Sort by" option, and choose the order in which you want them to be sorted. Keep in mind that the first column selected will be the primary sort, followed by the second column, and so on. This can help you organize your data even further and get more specific sorting results.

Similar threads

  • Computing and Technology
Replies
1
Views
958
  • Computing and Technology
Replies
3
Views
2K
Replies
27
Views
2K
  • Computing and Technology
Replies
5
Views
2K
  • Computing and Technology
Replies
14
Views
3K
  • Feedback and Announcements
Replies
6
Views
249
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
339
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
5K
Back
Top