This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-09-04 21:26:57

Validyk
New Scratcher
Registered: 2012-09-04
Posts: 2

Help with order and listing

At the end, have the sprite "say" the vaue of the largest number.

sort the numbers (display them in order, lowest to highest)?

these are the directions to my homework, anyone have a clue as to do this thanks?

Offline

 

#2 2012-09-04 23:11:00

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help with order and listing

There are many ways to sort lists.  Some are more complicated but quite fast, others are simpler, and a bit slower.  The easiest one that I can think of is to run through the list and search for the biggest number, and add it to a new list (the "sorted" list), deleting it from the original list.  Continue this for as long as the original list was.

Code:

set r to (length of list)
repeat (r)
1. find biggest number
2. delete above number from first list
3. add above number to second list
end

http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#3 2012-09-04 23:47:45

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: Help with order and listing

http://i.imgur.com/92dsD.gif

Try that. As it says in the comments, it only works if the numbers are integers, and also if you know the largest number. You can just set the largest number to a very large one if you don't know the largest number, like 9999999999999999999999 or something.


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#4 2012-09-05 12:51:06

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Help with order and listing

Hey Validyk; i noticed you posted another topic like this. In order to help keep the forums organized, i'll close this one, and keep all discussion to the other.  smile

Offline

 

Board footer