emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: Re: org table problems with sorting of some column
Date: Fri, 31 Dec 2021 09:20:41 +0100	[thread overview]
Message-ID: <87tuepjicm.fsf@mat.ucm.es> (raw)
In-Reply-To: 87czld4lkw.fsf@gmail.com

[-- Attachment #1: Type: text/plain, Size: 3407 bytes --]

>>> "TC" == Tim Cross <theophilusx@gmail.com> writes:

> Uwe Brauer <oub@mat.ucm.es> writes:

>> [[S/MIME Signed Part:Undecided]]
>> 
>> 
>> * Problem 1
>> 
>> I imported this column from a CVS file, so the date format was already chosen.
>> 
>> |       Date |
>> |------------|
>> | 05.05.2020 |
>> | 07.01.2021 |
>> | 07.01.2021 |
>> | 07.05.2020 |
>> | 09.03.2021 |
>> | 12.05.2020 |
>> | 13.02.2020 |
>> | 13.03.2020 |
>> | 13.03.2020 |
>> | 14.05.2020 |
>> | 15.02.2021 |
>> | 15.02.2021 |
>> | 17.02.2020 |
>> | 17.04.2020 |
>> | 20.04.2020 |
>> | 22.04.2020 |
>> | 23.06.2020 |
>> | 24.02.2021 |
>> | 24.04.2020 |
>> | 25.09.2020 |
>> | 25.11.2020 |
>> 
>> I'd like to sort these dates, but when I do that numerically it does not work as expected, any idea what to do.
>> 
>> 
>> * Problem 2
>> I'd like to order the column below descending 
>> 
>> |   Income |
>> |----------|
>> |   837.00 |
>> |   681.71 |
>> |   664.16 |
>> |   499.46 |
>> |   316.64 |
>> |   258.30 |
>> |   258.30 |
>> |   258.30 |
>> |   187.52 |
>> |   173.15 |
>> |   170.87 |
>> |   163.50 |
>> |   127.76 |
>> |   117.00 |
>> |    94.80 |
>> |    91.00 |
>> | 2.852.21 |
>> | 2.401.74 |
>> | 1.912.16 |
>> | 1.735.14 |
>> | 1.480.87 |
>> | 1.407.73 |
>> 
>> But again it does not work.
>> 
>> Any idea what to do?
>> 
>> regards
>> 
>> Uwe Brauer 
>> 
>> [[End of S/MIME Signed Part]]

> When reporting a problem, it would really help if you made it clear what
> you have tried and how it didn't work. From your description above, it
> is impossible to know if you actually tried using the built-in table
> sorting command and if you did, how you used it (what input, how you
> tried calling it etc). You also don't provide any details on what did
> not work - was it an error, was the sorting wrong, did nothing happen at
> all? There is also no details regarding your Emacs version or the org
> version you are running. 


Point taken. I am using 
GNU Emacs master 846ff294206c922da
org master commit e2fa3c4c4046b

> For problem 1, I suspect you will need to either change the date format
> or tell org what the date format is. It won't work trying to sort
> numerically as those values are not really numerical values. The date
> format you currently have I think is ambiguous - in Europe it would
> represent dd-mm-yyyy, but in the US it would represent mm-dd-yyyy. Best
> solution would be to convert the values into an ISO format i.e.
> yyyy-mm-dd.


It is a European format: dd.mm.yyyy 

So the most convenient way would be to tell org to use that format,
since changing the format to iso, would require to use a sophisticated
reg-expression.

I had a quick look but I cannot find a way to tell org to use the
European dd.mm.yyyy  format.




> For problem 2, I suspect the issue is because all your values are not
> numerical. The value 2.852.21 might be composed of numbers, but that is
> not a numerical value (what is the value of 1 + 2.852.21?). Org will
> interpret those values as strings and will sort them alphabetically.

Right, sorry 

| 2.852.21 |
| 2.401.74 |
| 1.912.16 |
| 1.735.14 |
| 1.480.87 |
| 1.407.73 |

Does not make much sense, I replace it by 

| 2852.21 |
| 2401.74 |
| 1912.16 |
| 1735.14 |
| 1480.87 |
| 1407.73 |

And everything worked as expected.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

  reply	other threads:[~2021-12-31  8:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-30 20:19 org table problems with sorting of some column Uwe Brauer
2021-12-31  1:00 ` Tim Cross
2021-12-31  8:20   ` Uwe Brauer [this message]
2021-12-31  8:25   ` Uwe Brauer
2022-01-01  0:05     ` Tim Cross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tuepjicm.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).