User Tag List

Results 1 to 9 of 9

Thread: sort numbers in list object

  1. #1
    Clicker Fusion 2.5 DeveloperiOS Export Module

    Join Date
    Jun 2011
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sort numbers in list object

    I've populated the list by adding new lines of global values as strings but I can't get the numbers to display in the list from lowest to highest. I've checked off the 'sort' checkbox in the list object settings properties. Any suggestions?
    Attached files Attached files

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,346
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Lines are sorted by alphabetical order, not numerical order.
    If your values are all integers (whole numbers), you can just add a few zeroes on the front, so that "5" becomes "005"; "50 becomes "050" etc.
    eg. Add line: Right$("000"+Str$(Global Value A), 4)
    Sorting floats is more problematic...

  3. #3
    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-onInstall Creator Pro

    Join Date
    Jun 2011
    Posts
    628
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Why you don't use List of numbers to do that?

    http://community.clickteam.com/showthread.php?t=69861
    Attached files Attached files

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export Module

    Join Date
    Jun 2011
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would have tried list of numbers but it's not iOS compatible. MuddyMole's suggestion works for me. Thanks for the help.

  5. #5
    Clickteam Clickteam
    Jeff's Avatar
    Join Date
    Jun 2006
    Location
    Battle Ground Washington
    Posts
    11,825
    Mentioned
    8 Post(s)
    Tagged
    2 Thread(s)
    As a side note
    I use an invisible high score object as a self sorting list of numbers sometimes.
    Feed in a bunch of "scores" and it will sort them for me and I can pull them back out to display them elsewhere.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    TheChiller's Avatar
    Join Date
    Jul 2010
    Location
    Germany
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The thing with the high score object is a good hint, unfortunately not working right now as the object seems not to take up scores I try to insert (either by action or by previous setting).
    Any idea how a list of dates, followed by (literally) events referring to each date could be sorted? I know I could use the string operators like "left two characters" but that doesn't quite help me sorting a list. Any hint appreciated

  7. #7
    Clicker Fusion 2.5Fusion 2.5+ DLC

    Join Date
    Sep 2010
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Right$("000", 4) operator is a nice expression, but I have a bit of a different problem with sorting. I can work around the fact that the list sorts lowest to highest, since I can just go backwards (need highest to lowest). The issue I have is for values below 1000. When I use the Right$("000", 4) operator in front of the value of a counter expression, I end up with fixed leading zeros in front of the value.

    example:

    0003 (which is fine)
    00044 (which is not fine)

    How do I fix that without having to create separate events for each set of values?

    Like (I'm trying to avoid):
    if value[counter] > 1000 then set counter to Right$("000", 4)+value[counter]
    if value[counter] > 100 then set counter to Right$("00", 3)+value[counter]
    if value[counter] > 10 then set counter to Right$("0", 2)+value[counter]

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,365
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    @FFomega: the correct expression should be Right$("000" + str$(value[counter]), 4). The whole purpose with the Right$ function is to control the number of leading 0's.


    @TheChiller: You can sort a list manually using nested fastloops. Loop through a list as many times as there are lines in it, and on each loop, scan the list for the highest value.
    You need two list objects for this. The original list and an empty list which we name SortedList.

    * Start of frame // Or whenever the list needs to be sorted
    - Start loop "SortList" Number of Lines in List times

    * OnLoop "SortList"
    - Set CounterHighestFound to 0
    - Start loop "ScanList" Number of Lines in List times

    * OnLoop "ScanList"
    + Val(List, loopindex("ScanList")) > CounterHighestFound

    - CounterHighestFound: Set current value to Val(List, loopindex("ScanList"))
    - CounterLineNumber: Set current value to loopindex("ScanList")

    * OnLoop "SortList"
    - SortedList: Add Line str$(CounterHighestFound)
    - List: Delete Line CounterLineNumber

    I didn't test this in Fusion so there might be mistakes, but I have done it earlier so I know it will work.
    Make sure that both List objects are set to be 0-base indexed as that makes it easier to work with fastloops, or else you need to add +1 to the loopindex.





  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    CruddyBuddy's Avatar
    Join Date
    May 2010
    Posts
    173
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jeff View Post
    As a side note
    I use an invisible high score object as a self sorting list of numbers sometimes.
    Feed in a bunch of "scores" and it will sort them for me and I can pull them back out to display them elsewhere.
    Any possibility of increasing the limits of this object for both name length, and more importantly, number of scores?

Similar Threads

  1. List object sort problem
    By Sumo in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 4th December 2012, 06:01 PM
  2. Sort number in list Vers 3 with fast loop?
    By daniele in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 28th July 2012, 05:02 PM
  3. List of numbers
    By ColdFire in forum Extension Development
    Replies: 5
    Last Post: 15th March 2012, 03:19 AM
  4. IconList Object - Sort List
    By Locaz00 in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 25th October 2008, 06:40 AM
  5. DataGrid sort by numbers
    By crugh in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 2nd September 2007, 01:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •