Search code examples
sortingnetlogoagent

NETLOGO- How to print values of variables in order of their label


I'm very new to Netlogo. I have a variable (U) for my breed (consumers) and I want to show them sorted by their label not randomly i.e.( I want it to print U of agent 0 then U of agent 1 etc.) Can someone please help me?

Thank You! Elham


Solution

  • Sort the agent set based on the who to create an ordered list. Then iterate on the resulting list using a for loop.

    foreach sort turtles
      [ the-turtle -> ask the-turtle [ show U ] ]