# Rank Date

**URL:** <https://community.glideapps.com/t/rank-date/30370>\
**Category:** Ask for Help\
**Tags:** custom-code\
**Created:** [August 12, 2021, 12:24pm UTC](https://community.glideapps.com/t/rank-date/30370 "2021-08-12T12:24:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [August 12, 2021, 12:24pm UTC](https://community.glideapps.com/t/rank-date/30370/1 "2021-08-12T12:24:32Z")

</div>

Here is a rank by date.  
To create the YC compatible table, I had to add a math column to format the date in short format.  
Note that I use in the attached list and divide the \ separator so as not to confuse ‘,’ which separates the date and time  
I also had to use a convertion according to the format of dates by regions. I hope it will work for you 🙂

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/e/cebb20ce5b3a3e9b0b7aeb9b145e3f25c10ddfaa.png)

YC link  
[https://Rank-Date.manun2.repl.co](https://Rank-Date.manun2.repl.co)

Source

EDIT V2  
**I found a bug ☹**  
**Uh, well I made a correction not super elegant but obviously it works**

EDIT V3  
I added an exception if the format of the Date array is not compliant (Short Format, Date & Time)

---

<div class="post-metadata">

**Author:** ![SantiagoPerez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/santiagoperez/32/16807_2.png) [@SantiagoPerez](https://community.glideapps.com/u/SantiagoPerez)\
**Post date:** [August 12, 2021, 12:55pm UTC](https://community.glideapps.com/t/rank-date/30370/2 "2021-08-12T12:55:56Z")

</div>

Hey @Manu.n

I have been trying to work on one that gives me an array of dates based on two specific dates but I’m stuck. Do you have any ideas on how to do it?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 12, 2021, 12:56pm UTC](https://community.glideapps.com/t/rank-date/30370/3 "2021-08-12T12:56:11Z")

</div>

Lovely! Will add to Notion for the weekend.

I’m wondering if we can theoretically sort an array based on another array.

Let’s say I want to return a name column from the database above based on dates.

A | Yesterday  
B | Tomorrow  
C | Today

Can we have something to return an array of B, C, A based on the latest date (from the date column)?

---

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [August 12, 2021, 12:57pm UTC](https://community.glideapps.com/t/rank-date/30370/4 "2021-08-12T12:57:55Z")

</div>

A B C are arrays?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 12, 2021, 12:58pm UTC](https://community.glideapps.com/t/rank-date/30370/5 "2021-08-12T12:58:43Z")

</div>

Maybe we can pass them in as arrays using a multiple relation/lookup or split text.

---

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [August 12, 2021, 1:00pm UTC](https://community.glideapps.com/t/rank-date/30370/6 "2021-08-12T13:00:34Z")

</div>

If I understood everything.

If the date = yesterday: return array A  
If the date = today: return array B  
If the date = tomorrow: return array C  
???

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 12, 2021, 1:26pm UTC](https://community.glideapps.com/t/rank-date/30370/7 "2021-08-12T13:26:38Z")

</div>

No, I mean we sort one array by another array.

Say Array 1 = [“A”, “B”, “C”], Array 2 = [“Yesterday”, “Tomorrow”, “Today”].

This is derived from the table above with 3 rows.

A | Yesterday  
B | Tomorrow  
C | Today

Then I want to sort array 2 descendingly and at the same time change the index of their respective values in array 1.

After sorting (by time) descendingly.

Array 2 = [“Tomorrow”, “Today”, “Yesterday”]  
Array 1 = [“B”, “C”, “A”]

To be clear, this is helpful with conducting templates for Quickchart/PDFs. @Jeff_Hager has been calling for this I think.

---

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [August 12, 2021, 1:32pm UTC](https://community.glideapps.com/t/rank-date/30370/8 "2021-08-12T13:32:23Z")

</div>

Yes it is possible (everything is possible).  
This works as long as the 2 source tables have the same number of items

---

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [August 12, 2021, 3:51pm UTC](https://community.glideapps.com/t/rank-date/30370/10 "2021-08-12T15:51:40Z")

</div>

so,  
I’m not sure to meet your expectations, but I did this:  
Sorting of the Data array (a, b, c, …) according to the date sorting.  
Sorting can be descending or ascending.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/5/85b74958b2168556f94de309b23b4d1d6adb7d06.png)

YC link  
[https://Sort-Array-by-Array-Date.manun2.repl.co](https://Sort-Array-by-Array-Date.manun2.repl.co)

Source

> **[Sort Array by Array Date](https://replit.com/@ManuN2/Sort-Array-by-Array-Date?v=1)**
>
> PROTOTYPE

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 13, 2021, 12:04am UTC](https://community.glideapps.com/t/rank-date/30370/11 "2021-08-13T00:04:10Z")

</div>

That looks about right! I will try this weekend and report back.

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [August 13, 2021, 2:59am UTC](https://community.glideapps.com/t/rank-date/30370/12 "2021-08-13T02:59:44Z")

</div>

Hola Thinh,

Anything like it?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/a/eab3e3d772cc86a2d587a099511d496da21f2769.jpeg)

I sorted and ranked the result based on Number column and joined the Name to know “the winners”.

Sorry for PIC quality 😥, I’m outside of my house without my laptop

Saludos

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 13, 2021, 3:24am UTC](https://community.glideapps.com/t/rank-date/30370/13 "2021-08-13T03:24:29Z")

</div>

Yes man! That’s exactly what I wanted.

Previously charts generated through a joined text column does not go well due to the inability to sort the values, especially dates.

Now I can build better solutions with this. Thanks @Manu.n and @gvalero!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 14, 2021, 1:40am UTC](https://community.glideapps.com/t/rank-date/30370/14 "2021-08-14T01:40:35Z")

</div>

Well reporting back…

All the solutions work perfectly in the builder but it still appears empty to the webhook no matter what I try…

---

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [August 14, 2021, 1:42am UTC](https://community.glideapps.com/t/rank-date/30370/15 "2021-08-14T01:42:26Z")

</div>

??? le webhook ??

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 14, 2021, 1:44am UTC](https://community.glideapps.com/t/rank-date/30370/16 "2021-08-14T01:44:04Z")

</div>

I have to pass a list of data to the webhook to generate a PDFMonkey pdf for my client. This was working just fine before, only need the date sorting to perfect it.

Solutions work fine in the builder, but the values don’t get passed at all to the webhook.

---

<div class="post-metadata">

**Author:** ![SantiagoPerez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/santiagoperez/32/16807_2.png) [@SantiagoPerez](https://community.glideapps.com/u/SantiagoPerez)\
**Post date:** [August 14, 2021, 1:45am UTC](https://community.glideapps.com/t/rank-date/30370/17 "2021-08-14T01:45:53Z")

</div>

Hey @ThinhDinh

@Francisco_Maldonado told me the exact same thing yesterday… He was trying to pass some info from a EC through a webhook but it did not work at all.

---

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [August 14, 2021, 1:46am UTC](https://community.glideapps.com/t/rank-date/30370/18 "2021-08-14T01:46:16Z")

</div>

Ah OK  
what is the type of column in return, an array ??

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 14, 2021, 1:46am UTC](https://community.glideapps.com/t/rank-date/30370/19 "2021-08-14T01:46:19Z")

</div>

Yeah, gotta hold it for now. Thanks for the info bro.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 14, 2021, 1:46am UTC](https://community.glideapps.com/t/rank-date/30370/20 "2021-08-14T01:46:36Z")

</div>

It return a string.

---

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [August 14, 2021, 1:47am UTC](https://community.glideapps.com/t/rank-date/30370/21 "2021-08-14T01:47:07Z")

</div>

to do a test, display the YC column in a text component for example, on the page with the Webhook action

[Next page](https://community.glideapps.com/t/rank-date/30370.md?page=2)
