• 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. Sorting the list of coordinates of a polygon

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 144
  • Views 15191
  • 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

Sorting the list of coordinates of a polygon

SS007
SS007 over 13 years ago

Hi,

I need to sort the list of coordinates of a polygon, first by their X coordinates and then by their Y coordinates. This will order the points, from top to bottom and left to right.

I tried using ciXYSortInsts() to sort the coordinate list as shown below. But the output is same as the input..

Am I using ciXYSortInsts() correctly, If not please tell me some other way to sort this list.

item=geGetSelSet()
(db:0x5c22c11e)
item~>xy
item~>xy
(nil)
y=item~>points
(((1.586 1.035)
 (1.586 0.795)
 (1.53 0.795)
 (1.53 0.91)
 (1.345 0.91)
 (1.345 0.795)
 (1.214 0.795)
 (1.214 1.035)
    )
)
ciXYSortInsts(y)
(((1.586 1.035)
 (1.586 0.795)
 (1.53 0.795)
 (1.53 0.91)
 (1.345 0.91)
 (1.345 0.795)
 (1.214 0.795)
 (1.214 1.035)
    )
)
 

Regards

SS

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 13 years ago

    That clearly won't work, because ciXYSortInsts is expecting you to provide a list of instance ids. You've not done that - you've given it a list of a list of coordinates. So it's doubly wrong - you have a list of lists, and each member is a coordinate not an instance id.

    I can't quite work out why you'd want to do this, but it's easy enough to write:

    procedure(MYxyLessp(a b)
      cond(
        (xCoord(a)<xCoord(b) t)
        (xCoord(a)>xCoord(b) nil)
        (yCoord(a)<yCoord(b) t)
        (t nil)
      )
    )

    y=car(geGetSelSet())~>points
    y=sort(y 'MYxyLessp)

    Be aware that sort is a destructive function and so you must use the return value rather than just assuming that the list is modified in place.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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