Ordered output |
Post Reply |
Author | |
Gali
Contributor Joined: 28.Jun.2018 Points: 10 |
Post Options
Thanks(0)
Posted: 16.Nov.2018 at 07:52 |
Hello,
I defined two objects(object1 and object2) and the relationship between them, as shown. The following figure shows an example. '1','2' and'3'are instances of Object1. 'a','b','c'...are instances of Object2. Now I want to output the contents from left to right (as the code shows, traverse object1 first, then traverse object2 associated with each object1). the result i want to obtain is '1abc2d3fe' but when i ran the program i get the result '1cab2d3fe'. I want to output from left to right by location, what should I do? foreach .Object1 { :context newline do >relationship { do .Object2 { :context newline } } } Yours, Gali |
|
stevek
MetaCase Joined: 11.Mar.2008 Points: 641 |
Answer Post Options Thanks(0) |
You can use 'orderby x num' to sort the loop by x co-ordinates. Note 'num' to sort as numbers: with the normal string sorting, '11' comes before '5'.
Note that I've removed the intermediate "do >relationship" loop. That's not necessary, unless you have more than one type of relationship between object types Object1 and Object2. If you do, you'll want to include that as part of the second loop, "do >relationship.Object2" rather than as an extra intermediate loop, which might defeat your ordering e.g. if the user drew relationships that weren't straight. I've also assumed that you actually want the order 1abc2d3ef, not ...fe :)
Edited by stevek - 16.Nov.2018 at 09:36 |
|
Post Reply | |
Tweet |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |