Autodesk Inventor Engineer-to-Order
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Sort using 4th element?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
Is there a way to sort a list using the 4th element?
sort(iList, :Ascending, key := :first)
sort(iList, :Ascending, key := :second)
sort(iList, :Ascending, key := :third)
sort(iList, :Ascending, key := :fourth)
Regards,
Luc
Solved! Go to Solution.
Re: Sort using 4th element?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
The key parameter takes any function. So to sort the fourth you need to create a function that gets the fourth element.
For example:
sort(iList, :Ascending, key := :fourth)
Function fourth(inList As List) As Any
Return nth(4, inList)
End Function
This will also work in other functions, such as Find
Find(myValue, iList, key:=:fourth)
************************************************************************************
If this post helps, please click the "thumbs up" to give kudos
If this post answers your question, please click "Accept as Solution"
************************************************************************************
Re: Sort using 4th element?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks Farren! That's exactly was I was looking for!
Now, I can I get this new function to remain in the functions list permanently?
Regards,
Luc
Re: Sort using 4th element?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You're welcome.
To make the function system wide, place it in "C:\Program Files\Autodesk\Inventor ETO Components 2012\Library\UserLib" (adjust for your version of eto)
Also, if you found my solution helpful I would appreciate any kudos you would like to give (Accept as Solution is great too). The two of these are used as a part of the formula to determine a users' "Ranking" and I'd like to increase mine :-p
************************************************************************************
If this post helps, please click the "thumbs up" to give kudos
If this post answers your question, please click "Accept as Solution"
************************************************************************************
Re: Sort using 4th element?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Great! Thanks again!
Maybe one day I'll be a mentor as well ![]()
Luc
Re: Sort using 4th element?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Farren's answer is correct.
Keep in mind though that the fourth function he wrote , using nth(4, mylist) does not work in the same way that first,second and third do, nth(4,{3,2,1}) returns 1 (i.e. the last element of the list), thirst({3,2}) returns novalue. No difference if your lists have the correct number of entities of course.
Elly
--
Autodesk
Elly Bachrach
Solutions Architect
Autodesk Global Services
Direct +1 (847) 676-2880
elly.bachrach@autodesk.com
Re: Sort using 4th element?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
The function below will cause it to work the same as :first, :second, and :third.
Function fourth(inList As List) As Any
If length(inlist) < 4 then
Return NoValue
Else
Return nth(4, inList)
End If
End Function
Inventor Certified Professional
________________________________________________________
If this post helps, please click the "Thumbs up"/"Kudos"
If this post gives the solution, please click "Accept as Solution"

