There really is no Sort method on the Components collection, keep in mind that not all components in DxDesigner have reference designators (like border symbols, supply, on-sheet/off-sheet connectors, ports, and annotate symbols, for example). I have used some public array sorting code found on Google, like you can see in this script: Reference Designator Assignment based on schematic location
Note that you may need specialized comparison functions, rather than just alphanumeric sorting, so that R2 comes before R13.
Perhaps more information about what you are trying to do with the script would enable someone to suggest alternate methods to suit your application. Not knowing what you want to do makes it a little difficult to suggest possible solutions. ie why do you need the items sorted by refdes? For what?
Another thing to consider is that some sort routines use numeric sorting only. So you get R1, R10, R11 R2, R3, R4, R5, R6, R7, R8, R9, instead of R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11. An alphanumeric sort is called for in this kind of case.
Also there are many sorting methods, and some of them are much faster than others. Quicksort is one of the fastest. If you are interested and can use vb.net code, I have implementations of alphanumeric quicksort for simple arraylists and arraylists of arrays.
If I really needed to sort the collection by refdes I would create a separate arraylist with just the refdes values, then quicksort it alphanumerically, then pull from the collection based on an iteration of the sorted arraylist.
I need a list with all Components and some of there Property’s.
The Project manager needs this information to calculate the cost off the Product, I need to export this Information in to a csv. I a exact given format so it can be imported to our ERP System.
Usually we export this list from the PCB with a lot more Information like Position Side...
In the PCB the sorting this is a easy thin to do and I will get the Components Alphabetically and numerically sorted. (R1,R2,R3,R4,R5,R6…)
It would be great if it would be as easy in the Dxd