Python Script: Sorted Sets
Python Script: Sorted Sets
(OP)
Hello!
Currently I'm working on a Python script and I'd like to know whether it is possible to create sets with entries sorted by a particular criterion?
In my case I need a node set with nodes arranged by their y-coordinates. Is it possible, for example, to generate a list of node labels, to rearrange the entries of the list and to create a set from that list afterwards?
Thanks a lot!
Currently I'm working on a Python script and I'd like to know whether it is possible to create sets with entries sorted by a particular criterion?
In my case I need a node set with nodes arranged by their y-coordinates. Is it possible, for example, to generate a list of node labels, to rearrange the entries of the list and to create a set from that list afterwards?
Thanks a lot!





RE: Python Script: Sorted Sets
Look for unsorted node sets in the manual.
Once you have sorted your node list as needed, you can create a so called "unsorted node set" out of it ("unsorted" because it is not sorted by node label). As unsorted node sets are not supported by /CAE, you'll probably have to use the keyword editor in some way in your script to add the set to your input file.
Hope this helps,
potf
RE: Python Script: Sorted Sets
Thank you potf!
RE: Python Script: Sorted Sets
PeterP1, you can check this pack:
http://pypi.python.org/pypi/sorteddict/1.2.1
Or code your own iterator using heaps:
http://en.wikipedia.org/wiki/Heap_(data_structure)
Right now python hasnt its own built-in implementations of sorted collections.
Also, if you are using JPython, you can use those java built-ins:
http://j
ht
http://jav