Hi,
Let’s say I have a set consisting of 5 elements such that: Set1 = {‘A’,‘B’,‘C’,‘D’,‘E’}.
How can I move some elements to the end of the set. For example:
Set1 = {‘A’, ‘D’,’E’,’B’,’C’}
Thanks!
Hi,
Let’s say I have a set consisting of 5 elements such that: Set1 = {‘A’,‘B’,‘C’,‘D’,‘E’}.
How can I move some elements to the end of the set. For example:
Set1 = {‘A’, ‘D’,’E’,’B’,’C’}
Thanks!
Best answer by gabiservidone
Below is a step-by-step example with some code to implement!
Define the original set:
Set Set1 {
Index : i;
Members : {'A', 'B', 'C', 'D', 'E'};
}
Create a parameter to define the sorting order:
Parameter p_NewOrder {
IndexDomain : i;
Definition : Data { 'A': 1, 'D': 2, 'E': 3, 'B': 4, 'C': 5 };
}
Define a new set with the OrderBy attribute:
Set OrderedSet1 {
SubsetOf : Set1;
OrderBy : p_NewOrder(i);
}
By executing this code, OrderedSet1 will be automatically sorted based on the values defined in p_NewOrder.
Already have an account? Login
Please use your business or academic e-mail address to register
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
Didn't find what you were looking for? Try searching on our documentation pages: