Sorting numbers

new topic     » topic index » view thread      » older message » newer message

Hello all,  I would first like to say thanks for the great forum and such a 
fun programming language.  Again, I am a beginner and would like to get some 
help.  I am sure that this is very simple for most of you guys, but I am 
stuck.  What I am trying to do is input 24 numbers and sum them together.  
Once I have the total, I need to figure out the largest number and subtract 
it from the total.  I figured the best way to do it is to sort the numbers 
from least to greatest and grab the last number, however this is my problem. 
  Here is the code that I was working on before I got stuck.



global procedure onClick_sparebutton()
atom AB1, AB2, AB3, AB4, AB5, AB6, AB7, AB8
atom  BC1, BC2, BC3, BC4, BC5, BC6, BC7, BC8
atom CA1, CA2, CA3, CA4, CA5, CA6, CA7, CA8
atom sumAB, sumBC, sumCA, sumtotal
atom sparenumber
object y

  AB1 = getNumber( ab1 )
  AB2 = getNumber( ab2 )
  AB3 = getNumber( ab3 )
  AB4 = getNumber( ab4 )
  AB5 = getNumber( ab5 )
  AB6 = getNumber( ab6 )
  AB7 = getNumber( ab7 )
  AB8 = getNumber( ab8 )
  BC1 = getNumber( bc1 )
  BC2 = getNumber( bc2 )
  BC3 = getNumber( bc3 )
  BC4 = getNumber( bc4 )
  BC5 = getNumber( bc5 )
  BC6 = getNumber( bc6 )
  BC7 = getNumber( bc7 )
  BC8 = getNumber( bc8 )
  CA1 = getNumber( ca1 )
  CA2 = getNumber( ca2 )
  CA3 = getNumber( ca3 )
  CA4 = getNumber( ca4 )
  CA5 = getNumber( ca5 )
  CA6 = getNumber( ca6 )
  CA7 = getNumber( ca7 )
  CA8 = getNumber( ca8 )

sumAB = AB1 + AB2 + AB3 + AB4 + AB5 + AB6 + AB7 + AB8
sumBC = BC1 + BC2 + BC3 + BC4 + BC5 + BC6 + BC7 + BC8
sumCA = CA1 + CA2 + CA3 + CA4 + CA5 + CA6 + CA7 + CA8
sumtotal = sumAB + sumBC + sumCA





I relize it is very imcomplete, but I just don't understand the sort 
function

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu