• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sort value pairs in a list by integer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sort value pairs in a list by integer


  • Subject: Re: Sort value pairs in a list by integer
  • From: Emmanuel <email@hidden>
  • Date: Fri, 4 Jul 2003 11:35:12 +0200

At 4:21 AM -0500 01/07/03, Joseph Weaks wrote:
>I can't get my head around this. I have a list that might contain between 5 to 10 pairs of values:
>
>set foobar to {"foo", 15, "bar", 6, "boo", 2, "far", 19}
>
>The numbers "go with" the preceding string and I want to return a list sorted in descending order by the integer value. ie. the result should be
>
>sortIt(foobar)
>-- {"far", 19, "foo", 15, "bar", 6, "boo", 2}

Here is what I would do.

- split the list into two lists (use a loop)
- tweak the "sort" handler that is provided in Smile (ask me for more details on this) or any other "sort" handler that you may find elsewhere so that it handle sorting two lists according to the order found in one
- use that "sort" handler, and finally make the two lists into one.

Below I publish my "sort2Lists" handler, which does what I say above, I think (I've not tested it much).

You have to convert it back from hexa to string (in Smile, cmd-shift-G).

6F6E20736F7274324C69737473286C2C20616C290D09736574206E20746F206C2773206C656E6774680D096966206E20B22031207468656E2072657475726E207B6C2C20616C7D0D096966206E203D2032207468656E0D0909736574207B782C20797D20746F206C0D0909736574207B61782C2061797D20746F20616C0D090969662078203E2079207468656E2072657475726E207B7B792C20787D2C207B61792C2061787D7D0D090972657475726E207B6C2C20616C7D0D09656E642069660D0973637269707420784F626A6563740D090970726F7065727479206C203A207B7D0D090970726F7065727479206C31203A207B7D0D090970726F7065727479206C32203A207B7D0D090970726F706572747920616C203A207B7D0D090970726F706572747920616C31203A207B7D0D090970726F706572747920616C32203A207B7D0D09656E64207363726970740D0973657420784F626A6563742773206C20746F206C0D0973657420784F626A656374277320616C20746F20616C0D0973657420784D6964646C6520746F20286E202B2031292064697620320D0973657420784D656469616E20746F20784F626A6563742773206C2773206974656D20784D6964646C650D097365742061784D656469616E20746F20784F626A656374277320616C2773206974656D20784D6964646C650D09726570656174207769746820692066726F6D203120746F2028784D6964646C65202D2031290D0909736574207820746F20784F626A6563742773206C2773206974656D20690D090973657420617820746F20784F626A656374277320616C2773206974656D20690D090969662078203C20784D656469616E207468656E0D09090973657420784F626A6563742773206C31277320656E6420746F20780D09090973657420784F626A656374277320616C31277320656E6420746F2061780D0909656C73650D09090973657420784F626A6563742773206C32277320656E6420746F20780D09090973657420784F626A656374277320616C32277320656E6420746F2061780D0909656E642069660D09656E64207265706561740D09726570656174207769746820692066726F6D2028784D6964646C65202B20312920746F206E0D0909736574207820746F20784F626A6563742773206C2773206974656D20690D090973657420617820746F20784F626A656374277320616C2773206974656D20690D090969662078203C20784D656469616E207468656E0D09090973657420784F626A6563742773206C31277320656E6420746F20780D09090973657420784F626A656374277320616C31277320656E6420746F2061780D0909656C73650D09090973657420784F626A6563742773206C32277320656E6420746F20780D09090973657420784F626A656374277320616C32277320656E6420746F2061780D0909656E642069660D09656E64207265706561740D09696620784F626A6563742773206C312773206C656E677468203E2031207468656E20736574207B784F626A6563742773206C312C20784F626A656374277320616C317D20746F20736F7274324C6973747328784F626A6563742773206C312C20784F626A656374277320616C31290D09696620784F626A6563742773206C322773206C656E677468203E2031207468656E20736574207B784F626A6563742773206C322C20784F626A656374277320616C327D20746F20736F7274324C6973747328784F626A6563742773206C322C20784F626A656374277320616C32290D0972657475726E207B784F626A6563742773206C31202620784D656469616E202620784F626A6563742773206C322C20784F626A656374277320616C3120262061784D656469616E202620784F626A656374277320616C327D0D656E6420736F7274324C697374730D

456D6D616E75656C oops Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Sort value pairs in a list by integer
      • From: Emmanuel <email@hidden>
References: 
 >Sort value pairs in a list by integer (From: Joseph Weaks <email@hidden>)

  • Prev by Date: Re: Moving IMAP messages in Entourage
  • Next by Date: Re: why won't force-eject work in a script, but will from command line?
  • Previous by thread: Re: Sort value pairs in a list by integer
  • Next by thread: Re: Sort value pairs in a list by integer
  • Index(es):
    • Date
    • Thread