Home > Community > Forums > Custom IC SKILL > sort List of Instances

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 sort List of Instances 

Last post Wed, May 15 2013 1:52 AM by Zdeno. 5 replies.
Started by Zdeno 14 May 2013 06:36 AM. Topic has 5 replies and 765 views
Page 1 of 1 (6 items)
Sort Posts:
  • Tue, May 14 2013 6:36 AM

    • Zdeno
    • Top 500 Contributor
    • Joined on Tue, Oct 12 2010
    • Geneve, Geneva
    • Posts 25
    • Points 290
    sort List of Instances Reply

    Hello,

     I would like to sort list of instances created by

    instList = setof(inst cv->instances inst->cellName == "cnf_digi")

    result is

    "|column_digi(1)|cnf_digi"

    "|column_digi(0)|cnf_digi"

    "|column_digi(15)|cnf_digi"

    "|column_digi(14)|cnf_digi"

    "|column_digi(13)|cnf_digi"

    "|column_digi(12)|cnf_digi"

    "|column_digi(11)|cnf_digi"

    "|column_digi(10)|cnf_digi"

    "|column_digi(9)|cnf_digi"

    "|column_digi(8)|cnf_digi"

    "|column_digi(7)|cnf_digi"

    "|column_digi(6)|cnf_digi"

    "|column_digi(5)|cnf_digi"

    "|column_digi(4)|cnf_digi"

    "|column_digi(3)|cnf_digi"

    "|column_digi(2)|cnf_digi"

     I tried used

    (sort instList lambda (A B)(alphalessp (A->name)(B->name))))

    But result is

    "|column_digi(1)|cnf_digi"

    "|column_digi(10)|cnf_digi"

    "|column_digi(11)|cnf_digi"

    "|column_digi(12)|cnf_digi"

    "|column_digi(13)|cnf_digi"

    "|column_digi(14)|cnf_digi"

    "|column_digi(15)|cnf_digi"

    "|column_digi(2)|cnf_digi"

    "|column_digi(3)|cnf_digi"

    "|column_digi(4)|cnf_digi"

    "|column_digi(5)|cnf_digi"

    "|column_digi(6)|cnf_digi"

    "|column_digi(7)|cnf_digi"

    "|column_digi(8)|cnf_digi"

    "|column_digi(9)|cnf_digi"

    alphalessp doesn't know sort integer in string as lessp. Is there any possibilities how to sort list of instances according to their names without complicated parsing string to integer and use lessp command?

     

    Thank you very much for answer in advance.

     

    Best regards,

     

    Zdenko Janoska

     

    • Post Points: 20
  • Tue, May 14 2013 7:41 AM

    Re: sort List of Instances Reply

    Hi Zdenko,

    (sort instList (lambda (A B) (minusp (alphaNumCmp A->name B->name t))))

    Should do what you want.

    Andrew.

    • Post Points: 35
  • Tue, May 14 2013 8:01 AM

    • Zdeno
    • Top 500 Contributor
    • Joined on Tue, Oct 12 2010
    • Geneve, Geneva
    • Posts 25
    • Points 290
    Re: sort List of Instances Reply

     Dear Andrew,

    thank you very much for quick response.That works perfektly.

      Zdenko

    • Post Points: 5
  • Wed, May 15 2013 12:52 AM

    • Zdeno
    • Top 500 Contributor
    • Joined on Tue, Oct 12 2010
    • Geneve, Geneva
    • Posts 25
    • Points 290
    Re: sort List of Instances Reply

     Hi Andrew,

    still there is a problem. I have list of terminals with names:

    "clk_cnt_column<17>"

    "clk_cnt_column<16>"

    "clk_cnt_column<15>"

    "clk_cnt_column<14>"

    "clk_cnt_column<13>"

    "clk_cnt_column<12>"

    "clk_cnt_column<11>"

    "clk_cnt_column<10>"

    "clk_cnt_column<9>"

    "clk_cnt_column<8>"

    "clk_cnt_column<7>"

    "clk_cnt_column<6>"

    "clk_cnt_column<5>"

    "clk_cnt_column<4>"

    "clk_cnt_column<3>"

    "clk_cnt_column<2>"

    "clk_cnt_column<1>"

    "clk_cnt_column<0>"

    "clk_cnt_column<255>"

    "clk_cnt_column<254>"

    =>

    "clk_cnt_column<19>"

    "clk_cnt_column<18>"

     

    and by using

    (sort termList (lambda (A B) (minusp (alphaNumCmp A->name B->name t))))

    in the result first 17 items are missing

    "clk_cnt_column<17>"

    "clk_cnt_column<18>"

    "clk_cnt_column<19>"

    "clk_cnt_column<20>"

     =>

    "clk_cnt_column<255>"

    if using plusp

     (sort termList (lambda (A B) (plusp (alphaNumCmp A->name B->name t))))

    just first 18 items are in the result

    "clk_cnt_column<17>"

    "clk_cnt_column<16>"

    "clk_cnt_column<15>"

    "clk_cnt_column<14>"

    "clk_cnt_column<13>"

    "clk_cnt_column<12>"

    "clk_cnt_column<11>"

    "clk_cnt_column<10>"

    "clk_cnt_column<9>"

    "clk_cnt_column<8>"

    "clk_cnt_column<7>"

    "clk_cnt_column<6>"

    "clk_cnt_column<5>"

    "clk_cnt_column<4>"

    "clk_cnt_column<3>"

    "clk_cnt_column<2>"

    "clk_cnt_column<1>"

    "clk_cnt_column<0>"

    Am I missing any concept with list sorting?

    Thank you for answer in advance.

    Best regards, Zdenko

     

     

     

     

     

    • Post Points: 20
  • Wed, May 15 2013 1:35 AM

    Re: sort List of Instances Reply

    Hi Zdenko,

    My guess is that you're looking at the variable termList, rather than using the return value of sort. sort is a destructive list operator; it modifies the list in place and so you should never rely on the variable that you passed in (it will only be correct if the first entry in the original list ended up as the first entry after sorting). So you should always do:

    termList=sort(termList ...)

    Regards,

    Andrew.

    • Post Points: 20
  • Wed, May 15 2013 1:52 AM

    • Zdeno
    • Top 500 Contributor
    • Joined on Tue, Oct 12 2010
    • Geneve, Geneva
    • Posts 25
    • Points 290
    Re: sort List of Instances Reply

    Thank you very much. That is true. Now it is working very vell.

    Regards, Zdenko

    • Post Points: 5
Page 1 of 1 (6 items)
Sort Posts:
Started by Zdeno at 14 May 2013 06:36 AM. Topic has 5 replies.