How to determine lowest to highest efficiently for 8 attribute values

jorkosjorkos Member, PRO Posts: 353

Hey guys, in my game I have 8 attribute values that get set and can change over the course of the gameplay. When I do a check, I want to be able to efficiently determine the lowest to highest values. What is the best way to do this? Any ideas? thank you so much!

Comments

  • colandercolander Member Posts: 1,610

    Do a search for bubble sort and see if that is what you are after.

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Hook up each attribute in the min function.

    For example: min(game.attribute1,game.attribute2,game.attribute3,game.attribute4) etc

    You can hook up 8 attributes in that function. Hook that up into a loop, determine the lowest, then change that value to a really high value so that it doesn't get picked later on.

    I have a video tutorial for it on GShelpers YouTube channel.

  • ArmellineArmelline Member, PRO Posts: 5,369

    To be sure of the best way to do what you want, you need to give us a few more details.

    The 8 attributes you have, do they need to be sorted from lowest to highest without changing the value of each attribute? That is, 8 more attributes would be needed in order to store the order (e.g. game.1st = game.Attribute 6, game.2nd = game.Attribute 5 etc.) or can you change the contents of the attributes, putting the lowest value into Attribute 1 and the highest in Attribute 8?

    Does that make sense?

  • jorkosjorkos Member, PRO Posts: 353

    I cannot change the value of the attributes when I do the check. All that I have are 8 real values. I need to know the order of lowest to highest. All I have is attribute1, attribute2, etc.

    Can someone code this logic for $20 - immediate payment via paypal. I'm struggling

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    @jorkos said:
    I cannot change the value of the attributes when I do the check. All that I have are 8 real values. I need to know the order of lowest to highest. All I have is attribute1, attribute2, etc.

    Can someone code this logic for $20 - immediate payment via paypal. I'm struggling

    Shot you a PM.

Sign In or Register to comment.