Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expressions to sort numbers in descending order.

  • Expressions to sort numbers in descending order.

    Posted by Obed Ampong on September 11, 2020 at 5:43 pm

    Hello,

    Please, I found this expression in the old feed but it is not working for AE 2020. I am actually trying to create something like a league table and would like to link the values to the source text to arrange them in descending order.

    a = [12,5,9,10,3];
    a.sort(function(a, b){return a – b});
    a.toSource();

    Could there be a way out?

    Thanks in advance

    Obed

    Obed Ampong replied 4 years, 2 months ago 4 Members · 6 Replies
  • 6 Replies
  • Brendon Murphy

    September 11, 2020 at 7:38 pm

    See if this does it:

    values = [12,5,9,10,3];

    sorted = values.sort(function(a, b){return b-a});

    sorted;

  • Obed Ampong

    September 22, 2020 at 1:31 am

    Thanks, it worked, but please one more thing I want it to displace on the y-axis like without commas but space intervals. Is there a way out?

    12

    10

    9

    3

  • Filip Vandueren

    September 22, 2020 at 7:51 am

    Last line should be:

    sorted.join(“\r”);

    Which joins the elements of the array into a string with return-characters inbetween every element.

  • Andrei Popa

    September 22, 2020 at 7:57 am

    I think he needs and extra “\r” for the empty lines

    sorted.join(“\r\r”)

  • Filip Vandueren

    September 22, 2020 at 8:04 am

    I’d do that with leading 🙂

  • Obed Ampong

    September 22, 2020 at 2:10 pm

    Thank you very much

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy