all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Sorting by author name first, then by year
@ 2021-05-06 22:49 pietru
  2021-05-24 11:37 ` Michael Heerdegen
  0 siblings, 1 reply; 4+ messages in thread
From: pietru @ 2021-05-06 22:49 UTC (permalink / raw)
  To: Help Gnu Emacs

I have a texinfo file with blocks as below, sorted first by year, then by author
surname using strings starting with "bibl-".  The contents of each block are embedded
within "@ifset" and "@end ifset".

Now I want to sort them, first according to surname, then by year, the earlier year
put first.

So I am looking to make a function that could do it.

--------

@ignore
* bibl-bouee-poli-etal-2013
@end ignore
@ifset show-bouee-poli-etal-2013
@sp 1
@anchor{bibl-bouee-poli-etal-2013}
2013.@: @sc{Bou@'ee, P.}; Poli, P.; Campillo, M.; Pedersen, H.; Briand,
X.; Roux, P.; @strong{Teleseismic correlations of ambient seismic noise
for deep global imaging of the Earth.} Geophysical Journal
International, Volume 194, Issue 2, Pages 844-848.
@uref{https://academic.oup.com/gji/article/194/2/844/2116979,,
[@sc{Complete Article}]} [@code{bibl-bouee-poli-etal-2013}].
@c Published: April 16, 2013.
@end ifset

@ignore
* bibl-verschuur-2013
@end ignore
@ifset show-verschuur-2013
@sp 1
@anchor{bibl-verschuur-2013}
2013.@: @sc{Verschuur, Dirk J.}; @strong{Seismic multiple removal
techniques.}
@uref{https://bookshop.eage.org/product/seismic-multiple-removal-techniques-past-present-and-future-revised-edition/,,
[@sc{Citation Doi}]} [@code{bibl-verschuur-2013}].
@c Published: January 01, 2013.
@end ifset








^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sorting by author name first, then by year
  2021-05-06 22:49 Sorting by author name first, then by year pietru
@ 2021-05-24 11:37 ` Michael Heerdegen
  2021-05-24 12:53   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2021-05-24 11:37 UTC (permalink / raw)
  To: pietru; +Cc: Help Gnu Emacs

pietru@caramail.com writes:

> I have a texinfo file with blocks as below, sorted first by year, then
> by author
> surname using strings starting with "bibl-".  The contents of each
> block are embedded
> within "@ifset" and "@end ifset".
>
> Now I want to sort them, first according to surname, then by year, the
> earlier year
> put first.
>
> So I am looking to make a function that could do it.

I think `sort-subr' is the function to use.  The call could look similar
to that in the implementation of `sort-paragraphs' but that command
unfortunately doesn't allow to specify a predicate, which you need.

Do you know how to write an according predicate?

Regards,

Michael.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sorting by author name first, then by year
  2021-05-24 11:37 ` Michael Heerdegen
@ 2021-05-24 12:53   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-05-24 18:04     ` Michael Heerdegen
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-05-24 12:53 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

>> I have a texinfo file with blocks as below, sorted first by
>> year, then by author surname using strings starting with
>> "bibl-". The contents of each block are embedded within
>> "@ifset" and "@end ifset".
>>
>> Now I want to sort them, first according to surname, then
>> by year, the earlier year put first.
>>
>> So I am looking to make a function that could do it.
>
> I think `sort-subr' is the function to use.

Or `sort-fields' depending on how the data look like.

(defun sort-second-field (beg end)
  (interactive "r")
  (sort-fields 2 beg end) )

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sorting by author name first, then by year
  2021-05-24 12:53   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-05-24 18:04     ` Michael Heerdegen
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Heerdegen @ 2021-05-24 18:04 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Or `sort-fields' depending on how the data look like.

The data in the original post is multiline, so I think `sort-fields'
can't be used.

Instead it looks like it would involve parsing the records to extract
the fields that sorting should respect, and then compose a sorting
predicate based on these fields.

Michael.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-24 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-06 22:49 Sorting by author name first, then by year pietru
2021-05-24 11:37 ` Michael Heerdegen
2021-05-24 12:53   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-24 18:04     ` Michael Heerdegen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.