# Possible to flip order of related pages in the picker?

**URL:** <https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073>\
**Category:** Questions\
**Tags:** v3\
**Created:** [November 22, 2023, 8:43pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073 "2023-11-22T20:43:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![yulie](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/yulie/32/13999_2.png) [@yulie](https://forum.getkirby.com/u/yulie)\
**Post date:** [November 22, 2023, 8:43pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/1 "2023-11-22T20:43:39Z")

</div>

I’ve got an events calendar with dates. A date can have multiple related pages. (It’s a website for a theatre director’s shows … Some nights, two shows get shown … the related pages are the shows.)

I was wondering if I can flip the order of the related pages in the picker … So that I have the most recent shows up top (they are the most likely ones to be picked). The one you see at the top (Woyzeck) is the oldest show. The pages have standard Kirby sorting … 1\_Woyzeck is the folder of the oldest show.

This is the way it looks in the panel:

 ![Bildschirmfoto 2023-11-22 um 21.33.36](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/5/57020b25dcc9d3a85f253585d586e5ad3db14ade.jpeg)

And this is the relevant part from the blueprint:

```auto
    sections:
      werke:
        type: fields
        fields:
          related:
            translate: false
            label: Gezeigte Werke
            type: pages
            query: site.find('werkliste')
            info: "({{ page.jahr }})"
            empty: "Keine Werke ausgewählt"
            link: false

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 22, 2023, 8:46pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/2 "2023-11-22T20:46:55Z")

</div>

If you sort them within your query by whatever you want to sort by, it should work.

---

<div class="post-metadata">

**Author:** ![yulie](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/yulie/32/13999_2.png) [@yulie](https://forum.getkirby.com/u/yulie)\
**Post date:** [November 22, 2023, 8:48pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/3 "2023-11-22T20:48:33Z")

</div>

Oh, I didn’t know I could sort in the query … I haven’t found an example in the docs.

I went here for reference:

> **[Pages](https://getkirby.com/docs/reference/panel/fields/pages#query-pages)**
>
> A pages select field that allows to select one or multiple related pages

```auto
(https://getkirby.com/docs/reference/panel/fields/pages#query-pages)

```

… but didn’t find anything about sorting…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 22, 2023, 8:52pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/4 "2023-11-22T20:52:19Z")

</div>

The actually selected ones will appear in the order in which they were selected though. Just adding this here in case…

---

<div class="post-metadata">

**Author:** ![yulie](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/yulie/32/13999_2.png) [@yulie](https://forum.getkirby.com/u/yulie)\
**Post date:** [November 22, 2023, 8:53pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/5 "2023-11-22T20:53:36Z")

</div>

Yes, and that’s great! I only meant the sorting inside the picker… is there any way to modify that sorting?

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [November 22, 2023, 9:06pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/6 "2023-11-22T21:06:56Z")

</div>

You can read the following reference article to get a better understanding of sorting in the Blueprint:

> **[Pages section](https://getkirby.com/docs/reference/panel/sections/pages#sorting)**
>
> List and edit subpages

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 22, 2023, 9:08pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/7 "2023-11-22T21:08:58Z")

</div>

That’s a section though, a pages field has different options, so you cannot apply this to a pages field!

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [November 22, 2023, 9:17pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/8 "2023-11-22T21:17:48Z")

</div>

Then this should be the right solution.  
I have tried it and the current page is listed at the top of the dialog box.

> [@How to sort a pages field by date?](https://forum.getkirby.com/t/how-to-sort-a-pages-field-by-date/15097/5):
>
> query: page.children.sortBy('date', 'desc') That will sort the pages by date. Additionally, you can add the date as info in the select field: query: page.children.sortBy('date', 'desc') info: "{{ page.date.toDate('Ymd') }}"

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 22, 2023, 9:19pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/9 "2023-11-22T21:19:39Z")

</div>

> [@GB\_DESIGN](#):
>
> Then this should be the right solution.

Right, this is what I already suggested.

---

<div class="post-metadata">

**Author:** ![yulie](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/yulie/32/13999_2.png) [@yulie](https://forum.getkirby.com/u/yulie)\
**Post date:** [November 22, 2023, 9:34pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/10 "2023-11-22T21:34:22Z")

</div>

> [@How to sort a pages field by date?](https://forum.getkirby.com/t/how-to-sort-a-pages-field-by-date/15097/5):
>
> sortBy(‘date’, ‘desc’)

If I modify my query that currently looks like this

```auto
query: site.find('werkliste')

```

to that

```auto
query: site.find('werkliste').sortBy('jahr', 'desc')

```

I get the following error in the panel:

 ![Bildschirmfoto 2023-11-22 um 22.33.58](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/a/ae7aa4028a7c23fd61b6a3963b3416b648f5fab7.png)

… thoughts?

this being the respective blueprint:

```auto
title: Werk

columns:
  - width: 1/2
    sections:
      textinformationen:
        type: fields
        fields:
          genre:
            help: z. B. Theater/Live-Film 
            type: text
            width: 1/2
            icon: tag
          ort:
            help: z. B. Theater Basel
            type: text
            width: 1/2
            icon: home
            placeholder: optional
          jahr:
            label: Jahr(e)
            help: z. B. 2018/2019
            type: text
            translate: false
            width: 1/2
            icon: calendar
            maxlength: 9
          aktualitaet:
            label: Aktualität
            type: checkboxes
            translate: false
            width: 1/2
            default: aktuell
            options:
              aktuell: aktuell
            help: Wird das Werk noch gezeigt?
          beschreibung:
            type: writer
            marks:
              - link
              - bold
              - italic
            nodes: false
          credits_personen:
            type: structure
            label: Credits (Personen)
            fields:
              rolle:
                label: Rolle(n)
                type: text
              name:
                label: Name(n)
                type: text
          credits_institutionen:
            type: writer
            marks:
              - link
              - bold
              - italic
            nodes: false
            label: Credits (Institutionen)
            icon: home
            help: "z. B. Mit Unterstützung durch den Fachausschuss Tanz & Theater der Kantone Basel-Stadt und Basel-Landschaft."
          kritiken:
            type: blocks
            fieldsets:
              - quote
            help: "Tipp: Sollte es für dieses Werk in der aktuell ausgewählten Sprache keine Kritiken geben, lösche bitte alle leeren Blöcke, damit auf der Website kein leerer dunkler Kasten angezeigt wird &hellip; eigentlich ist es so gebaut, dass das nicht passiert, aber sicher ist sicher 😉"
  - width: 1/2
    sections:
      bilder:
        help: "<p>Tipp: Das erste Bild in dieser Liste wird als großformatiges Bild auf der Seite des Werkes angezeigt. Bitte wähle hierfür ein Querformat, idealerweise 16/9.</p><p>Vermeide bitte Kommata in den Namen der Bilddateien, da diese zu Fehlern in der Funktionalität des CMS führen können.</p><p>Du kannst pro Sprache eine eigene Sortierung wählen.</p>"
        type: files
        template: bild
        info: "{{ file.dimensions }}"
        layout: cards
        size: small
        limit: 100
        image:
          ratio: 1/1
      filmlinks:
        type: fields
        fields:
          filme:
            label: Videos
            help: "Tipp: YouTube- und Vimeo-Links sind möglich.<br><br>Sollte es für dieses Werk in der aktuell ausgewählten Sprache keine Videos geben, lösche bitte alle leeren Blöcke, damit auf der Website kein Weißraum angezeigt wird."
            type: blocks
            fieldsets:
              - video
      zusatzinformationen:
        type: fields
        fields:
          line:
            type: line
          silbentrennung:
            help: "<p>z. B. Martin Luther Propaganda&amp;shy;symposium</p><p>Tipp: Falls, speziell in deutschsprachigen Titeln, Wörter zu lang sind, können die Silben dieser Wörter per HTML-Tag <em>&amp;shy;</em> getrennt werden.</p>"
            type: text
            icon: code

```

So unfortunately, the solution you suggested doesn’t work…

---

<div class="post-metadata">

**Author:** ![yulie](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/yulie/32/13999_2.png) [@yulie](https://forum.getkirby.com/u/yulie)\
**Post date:** [November 22, 2023, 9:42pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/11 "2023-11-22T21:42:17Z")

</div>

Never mind, I figured it out! I was because I needed to show the CHILDREN of “Werkliste”, not “Werkliste” itself … it threw an error because the parent of the pieces doesn’t have a year field … only it’s children:

```auto
site.find('werkliste').children.sortBy('jahr', 'desc')

```

Thank you so much for your support. Y’all rock 🙂

–

But: “flip” doesn’t seem to be available…

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [November 22, 2023, 9:45pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/12 "2023-11-22T21:45:46Z")

</div>

> [@yulie](#):
>
> But: “flip” doesn’t seem to be available…

`asc` or `desc` changes the order.

---

<div class="post-metadata">

**Author:** ![yulie](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/yulie/32/13999_2.png) [@yulie](https://forum.getkirby.com/u/yulie)\
**Post date:** [November 22, 2023, 9:48pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/13 "2023-11-22T21:48:37Z")

</div>

You know what? I did it.

```auto
site.find('werkliste').children.listed.flip

```

WORKS!

It only works though when all query results are **listed** objects. So “listed” was missing in order for it to work 🙂

This is what it looks like now (so cool):

 ![Bildschirmfoto 2023-11-22 um 22.47.19](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/d/d51abbc77a8fe85d79bc8bd19d0103ff16068d54.jpeg)

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [November 22, 2023, 9:50pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/14 "2023-11-22T21:50:49Z")

</div>

👍 Great that you have found a solution.  
And that you were able to gather insights.

---

<div class="post-metadata">

**Author:** ![yulie](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/yulie/32/13999_2.png) [@yulie](https://forum.getkirby.com/u/yulie)\
**Post date:** [November 22, 2023, 9:56pm UTC](https://forum.getkirby.com/t/possible-to-flip-order-of-related-pages-in-the-picker/30073/15 "2023-11-22T21:56:54Z")

</div>

@GB_DESIGN & @texnixe thank you so much for pointing me in the right direction … I really appreciate it 🙂
