Issue 103166 - Sorting by date does not work correctly
Summary: Sorting by date does not work correctly
Status: REOPENED
Alias: None
Product: Calc
Classification: Application
Component: editing (show other issues)
Version: OOO310m11
Hardware: HP (PA-RISC) Windows Vista
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-28 03:35 UTC by unclerice
Modified: 2015-09-13 21:30 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Open document spreadsheet with sorting failure (57.75 KB, text/plain)
2009-06-28 15:39 UTC, unclerice
no flags Details
Budget Calc file does not sort by date correctly (39.69 KB, application/vnd.oasis.opendocument.spreadsheet)
2009-06-28 15:52 UTC, unclerice
no flags Details
Three date formats that sort in the same sequence (60.15 KB, image/png)
2015-09-13 21:22 UTC, orcmid
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description unclerice 2009-06-28 03:35:28 UTC
When I try to sort any spreadsheet it sorts by some unknown irrelevant factor.
Example 1: Here is a budget spreadsheet prior to sorting:
http://picasaweb.google.com/yoneward/Computers#5352199557477103586
Here is the same spreadsheet after trying to sort by the date A to Z:
http://picasaweb.google.com/yoneward/Computers#5352199558007346434
Example 2: Here is a spreadsheet I created to track game data prior to sorting:
http://picasaweb.google.com/yoneward/Computers#5352199559487647026
Here is what it looks like after sorting A to Z:
http://picasaweb.google.com/yoneward/Computers#5352199557989885026
This problem did not exist in prior versions of Calc.
Comment 1 jbf.faure 2009-06-28 12:41:49 UTC
Please provide a step by step scenario and a sample document which shows the
problem.
Comment 2 unclerice 2009-06-28 15:39:03 UTC
Created attachment 63255 [details]
Open document spreadsheet with sorting failure
Comment 3 unclerice 2009-06-28 15:50:36 UTC
I select a portion of a table Starting from the 'A' column over to the 'L' column 
and down a few rows to highlight the relevant data and click the sort button in 
the tool bar. None of the columns sort to any recognizable measure. With File: 
Hexazon, I select the entire table From "A" to "P" and click the sort button. 
There is no recognizable reason in the manner it sorts.
Comment 4 unclerice 2009-06-28 15:52:43 UTC
Created attachment 63256 [details]
Budget Calc file does not sort by date correctly
Comment 5 jbf.faure 2009-06-28 16:10:01 UTC
OK, please try the following : select the column range from L to A so that the
cell that is selected before you click the sort button is in column A.
The behavior of sort function has been changed with version 3.1 : now when
sorting a set of columns, it is done by the column containing the current cell,
even it is not the first column.
And now, by default, the first cell in the column is used as label.
Comment 6 unclerice 2009-06-28 16:35:04 UTC
Ah Ha! That works. I can see this possibly working better, because, as I recall, 
it used to be you could only sort by the left selected column before.
Comment 7 jbf.faure 2009-06-28 17:33:36 UTC
Ok, closing. Thanks.
Comment 8 albrecht Faust 2015-09-13 16:03:31 UTC
Comment on attachment 63256 [details]
Budget Calc file does not sort by date correctly

Calc sorts according to the string representation of the date - but this does not help in case of a date format DD.MM.YYYY
Comment 9 orcmid 2015-09-13 16:29:49 UTC
(In reply to albrecht Faust from comment #8)
> Comment on attachment 63256 [details]
> Budget Calc file does not sort by date correctly
> 
> Calc sorts according to the string representation of the date - but this
> does not help in case of a date format DD.MM.YYYY

Ooh, right. It should sort by the DateTime numerical value that is actually in the cell.  That will always get it right unless the user does something very strange.  

This would depend on the cell actually being Numeric but formatted to present as a date or time-span.  If any of the cells involved have text value, there's not much to be done, although sorting might help the user recognize what can be an easy mistake.

I am reopening until we verify this aspect.
Comment 10 mroe 2015-09-13 19:01:51 UTC
I can't see any problem. The sort button sorts by the column where the cell cursor is in place.

If the cell cursor is located in column A (select from L to A) it sorts the dates right. What is your result?
Comment 11 orcmid 2015-09-13 21:22:16 UTC
Created attachment 84914 [details]
Three date formats that sort in the same sequence

(In reply to albrecht Faust from comment #8)
> Comment on attachment 63256 [details]
> Budget Calc file does not sort by date correctly
> 
> Calc sorts according to the string representation of the date - but this
> does not help in case of a date format DD.MM.YYYY

I just checked this in Apache OpenOffice 4.1.1.  In all cases, whatever the formatting used for the date, the columns are sorted by the chronological progression of the dates.

Here are the ones I tried.  

I will check your exact use of DD.MM.YYYY to see if that makes any difference.
Comment 12 orcmid 2015-09-13 21:30:45 UTC
(In reply to orcmid from comment #11)
> Created attachment 84914 [details]
> Three date formats that sort in the same sequence
  
> 
> I will check your exact use of DD.MM.YYYY to see if that makes any
> difference.

In the third column, I used the explicit format DD.MM.YYYY and it all worked, even after resorting the 5 rows.

Please check for how your DD.MM.YYYY cells are formatted as dates.  I notice, on an en_US installation, if I enter 25.01.1939 without specifying that the cell is for a date format, the entry is treated as a text string (and left-justified in the cell).

If I specify that format for the cells first, entries work just fine.

So the problem some may experience is that DD.MM.YYYY in their locale is not automatically recognized as a date unless the cell format is specified first?