Subject: bug#35513: (setq gnus-thread-sort-functions '(gnus-thread-sort-by-number)) seems not to work always.

From: Uwe Brauer <[email-masked]>
Date: Tue, 30 Apr 2019 23:45:21 +0200

I have set

(setq gnus-thread-sort-functions '(gnus-thread-sort-by-number)) 
but also 
(setq gnus-thread-ignore-subject nil)

Now look at the following ordering when threading is on.

 89532 [  Uwe Braue] Uwe Brauer  [First message sent       ] Tue, 30 Apr 2019 23:27:28 +0200 4.6k 1   
     89534 [  Uwe Braue] Uwe Brauer  [                         ] Tue, 30 Apr 2019 23:27:59 +0200 8.1k 3   
         89536 [  Uwe Braue] Uwe Brauer  [                         ] Tue, 30 Apr 2019 23:28:33 +0200 16k ?   
 89540 [  Uwe Braue] Uwe Brauer  [[New subject] (was: First] Tue, 30 Apr 2019 23:32:05 +0200 12k ?   
 89538 [  Uwe Braue] Uwe Brauer  [I sent a new message whic] Tue, 30 Apr 2019 23:29:54 +0200 7.8k 1   
 89542 [  Uwe Braue] Uwe Brauer  [[New message references k] Tue, 30 Apr 2019 23:32:43 +0200 12k ?   

You will see that  89540 is ordered *before*  89538.

How did that happen? Here is a step by step instruction.
(setq gnus-thread-ignore-subject nil)

Sent some message to say your other email address and reply via followup
that gives 
 89532 [  Uwe Braue] Uwe Brauer  [First message sent       ] Tue, 30 Apr 2019 23:27:28 +0200 4.6k 1   
     89534 [  Uwe Braue] Uwe Brauer  [                         ] Tue, 30 Apr 2019 23:27:59 +0200 8.1k 3   
         89536 [  Uwe Braue] Uwe Brauer  [                         ] Tue, 30 Apr 2019 23:28:33 +0200 16k ?   

Then I sent a new message which  does not belong to the thread, that is 
 89538 [  Uwe Braue] Uwe Brauer  [I sent a new message whic] Tue, 30 Apr 2019 23:29:54 +0200 7.8k 1   

Now I reply to  89536, change the subject but leave the reference
intact, that results in   89540, placed *before* 89538, which is not
correct. 

I reply (followup again to message 89536, change the subject and remove
the reference that indeed message 89542 is ordered correctly.

I think the current behavior is not intuitive and should be changed:
Messages should be always ordered (in that setting I described above) by
their number independent whether it has it source in a thread.

Regards

Uwe Brauer 

Gnus v5.13
GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2018-04-26
200 news.gmane.org InterNetNews NNRP server INN 2.6.1 ready (posting ok)
100 Legal commands
  ARTICLE [message-ID|number]
  AUTHINFO USER name|PASS password|SASL mechanism [initial-response]|GENERIC program [argument ...]
  BODY [message-ID|number]
  CAPABILITIES [keyword]
  COMPRESS DEFLATE
  DATE
  GROUP newsgroup
  HDR header [message-ID|range]
  HEAD [message-ID|number]
  HELP
  IHAVE message-ID
  LAST
  LIST [ACTIVE [wildmat]|ACTIVE.TIMES [wildmat]|COUNTS [wildmat]|DISTRIB.PATS|DISTRIBUTIONS|HEADERS [MSGID|RANGE]|MODERATORS|MOTD|NEWSGROUPS [wildmat]|OVERVIEW.FMT|SUBSCRIPTIONS [wildmat]]
  LISTGROUP [newsgroup [range]]
  MODE READER
  NEWGROUPS [yy]yymmdd hhmmss [GMT]
  NEWNEWS wildmat [yy]yymmdd hhmmss [GMT]
  NEXT
  OVER [range]
  POST
  QUIT
  STARTTLS
  STAT [message-ID|number]
  XGTITLE [wildmat]
  XHDR header [message-ID|range]
  XOVER [range]
  XPAT header message-ID|range pattern [pattern ...]
Report problems to <[email-masked]>.
.
382 Begin TLS negotiation now
100 Legal commands
  ARTICLE [message-ID|number]
  AUTHINFO USER name|PASS password|SASL mechanism [initial-response]|GENERIC program [argument ...]
  BODY [message-ID|number]
  CAPABILITIES [keyword]
  COMPRESS DEFLATE
  DATE
  GROUP newsgroup
  HDR header [message-ID|range]
  HEAD [message-ID|number]
  HELP
  IHAVE message-ID
  LAST
  LIST [ACTIVE [wildmat]|ACTIVE.TIMES [wildmat]|COUNTS [wildmat]|DISTRIB.PATS|DISTRIBUTIONS|HEADERS [MSGID|RANGE]|MODERATORS|MOTD|NEWSGROUPS [wildmat]|OVERVIEW.FMT|SUBSCRIPTIONS [wildmat]]
  LISTGROUP [newsgroup [range]]
  MODE READER
  NEWGROUPS [yy]yymmdd hhmmss [GMT]
  NEWNEWS wildmat [yy]yymmdd hhmmss [GMT]
  NEXT
  OVER [range]
  POST
  QUIT
  STARTTLS
  STAT [message-ID|number]
  XGTITLE [wildmat]
  XHDR header [message-ID|range]
  XOVER [range]
  XPAT header message-ID|range pattern [pattern ...]
Report problems to <[email-masked]>.
.