• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. sort lists in SKILL/OCEAN

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 144
  • Views 7703
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

sort lists in SKILL/OCEAN

mbchang
mbchang over 12 years ago

 I have a list which includes several lists inside. Is there any way that I can sort the lists alphabetly based on the first part of each list (signal name)?

 

Thanks!

list( 

list("V105A_ymax_v9overshoot_1"   float(0.9975)  float(1.1025) "[V]"   )
list("V105A_riseTime_v9ramptime_1"   float(300u)  float(2m) "[s]"   )
list("V5A_DS3_delay10_v5a_on_1"   float(0.0)  float(500u) "[s]"   )
list("V33A_DSW_peakToPeak_v4vripple_1"   float(0.0)  float(50.0m) "[V]"   )
list("V5A_DS3_ymin_v2pgoodincr_1"   float(4.65)  float(4.85) "[V]"   )
list("DPWROK_delay90_pwrok_delay_1"   float(10m)  float(15m) "[s]"   )
list("V33A_DSW_average_v4voutavg_1"   float(3.135)  float(3.465) "[V]"   )
list("V105A_ymin_v9pgoodincr_1"   float(0.965)  float(1.03) "[V]"   )

)

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    The simplest way to do this is to use sortcar() with your example. Assuming myList contains the list:

    myList=sortcar(myList 'alphalessp)

    That outputs this:

     (("DPWROK_delay90_pwrok_delay_1" 0.01 0.015 "[s]")
        ("V105A_riseTime_v9ramptime_1" 0.0003 0.002 "[s]")
        ("V105A_ymax_v9overshoot_1" 0.9975 1.1025 "[V]")
        ("V105A_ymin_v9pgoodincr_1" 0.965 1.03 "[V]")
        ("V33A_DSW_average_v4voutavg_1" 3.135 3.465 "[V]")
        ("V33A_DSW_peakToPeak_v4vripple_1" 0.0 0.05 "[V]")
        ("V5A_DS3_delay10_v5a_on_1" 0.0 0.0005 "[s]")
        ("V5A_DS3_ymin_v2pgoodincr_1" 4.65 4.85 "[V]")
    )

    In the absence of sortcar, you could do:

    myList=sort(myList lambda((a b) alphalessp(car(a) car(b))))

    In other words, the second argument to sort is a function that compares two values and returns t if the first is "less" than the second. You can then do whatever comparison you like - here I'm using alphalessp on the car of each entry, which is your signal name here. I could equally well sort on the second entry in each list (the numbers) by doing:

    myList=sort(myList lambda((a b) cadr(a)<cadr(b)))

    And so on.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    The simplest way to do this is to use sortcar() with your example. Assuming myList contains the list:

    myList=sortcar(myList 'alphalessp)

    That outputs this:

     (("DPWROK_delay90_pwrok_delay_1" 0.01 0.015 "[s]")
        ("V105A_riseTime_v9ramptime_1" 0.0003 0.002 "[s]")
        ("V105A_ymax_v9overshoot_1" 0.9975 1.1025 "[V]")
        ("V105A_ymin_v9pgoodincr_1" 0.965 1.03 "[V]")
        ("V33A_DSW_average_v4voutavg_1" 3.135 3.465 "[V]")
        ("V33A_DSW_peakToPeak_v4vripple_1" 0.0 0.05 "[V]")
        ("V5A_DS3_delay10_v5a_on_1" 0.0 0.0005 "[s]")
        ("V5A_DS3_ymin_v2pgoodincr_1" 4.65 4.85 "[V]")
    )

    In the absence of sortcar, you could do:

    myList=sort(myList lambda((a b) alphalessp(car(a) car(b))))

    In other words, the second argument to sort is a function that compares two values and returns t if the first is "less" than the second. You can then do whatever comparison you like - here I'm using alphalessp on the car of each entry, which is your signal name here. I could equally well sort on the second entry in each list (the numbers) by doing:

    myList=sort(myList lambda((a b) cadr(a)<cadr(b)))

    And so on.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information