# sorting question

**URL:** <https://discourse.citationstyles.org/t/sorting-question/50>\
**Category:** CSL Development\
**Created:** [March 29, 2005, 1:18am UTC](https://discourse.citationstyles.org/t/sorting-question/50 "2005-03-29T01:18:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruce\_D\_Arcus](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@Bruce\_D\_Arcus](https://discourse.citationstyles.org/u/Bruce_D_Arcus)\
**Post date:** [March 29, 2005, 1:18am UTC](https://discourse.citationstyles.org/t/sorting-question/50/1 "2005-03-29T01:18:19Z")

</div>

cross-posting here …

I’m working on sorting configuration, but am running into a fundamental  
design question:

When dealing with reference lists, is the first field always the sort  
key?

For example, in a typical reference list, the creator name will be the  
sort key. If there is no creator, there needs to be rules to specify  
substitutes. For a book, it might be to substitute the phrase  
"Anonymous." For an article, it might be to substitute the periodical  
title.

In a cite key style citation class, likewise, it seems the sort key is  
the citation key; e.g.:

[doe99] Doe, J. …

Is this a reliable general rule then? Or should instead the layout and  
the sorting be seen as completely separate?

I’m leaning towards a structure like:

It’s possible for me to do some RELAX NG magic and condition the layout  
of the following elements based on the sort-key value, but I’m not sure  
I should do that or not.

The other issue I’ve not resolved is how to handle CDATA, though one  
solution is to have:

 creator container-title creator Anonymous 

Bruce

---

<div class="post-metadata">

**Author:** ![sandersbud4](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/sandersbud4/32/292_2.png) [@sandersbud4](https://discourse.citationstyles.org/u/sandersbud4)\
**Post date:** [January 9, 2023, 5:46pm UTC](https://discourse.citationstyles.org/t/sorting-question/50/2 "2023-01-09T17:46:01Z")

</div>

[quote=“Bruce\_D\_Arcus, post:1, topic:50”]  
I’m working on sorting configuration, but am running into a fundamental  
design question:  
In general, it is a good idea to separate the layout of a reference list from its sorting. This allows you to change the layout without affecting the sorting, and vice versa.

It is a good idea to specify the sorting key explicitly, rather than relying on an implicit rule such as “the first field is always the sort key.” This makes your sorting rules more explicit and easier to understand.

For example, you could specify the sorting key as a separate field in your reference list, like this:

```auto
sort_key: Doe, J.
creator: Doe, J.
title: The Importance of Being Anonymous

```

Alternatively, you could specify the sorting key as a special field in each reference, like this:

```auto
[doe99]
sort_key: doe99
creator: Doe, J.
title: The Importance of Being Anonymous

```

In either case, you can then use the sorting key to sort your reference list, without having to worry about the layout of the references.

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [January 9, 2023, 8:06pm UTC](https://discourse.citationstyles.org/t/sorting-question/50/3 "2023-01-09T20:06:41Z")

</div>

Have you seen you’ve answered a question from 2005?
