Computer Science Canada records |
Author: | Tallguy [ Thu Apr 23, 2009 7:51 am ] | ||
Post subject: | records | ||
so doing a records assignment, this is the section i'm having problems with. i have to sort the records, but when i run it i get this error "operands of comparison operators must be scalars, sets or strings" so i've tried strint, intstr, still getting the error suggestions?
|
Author: | DemonWasp [ Thu Apr 23, 2009 8:12 am ] |
Post subject: | RE:records |
Your record type is a custom type. Turing has no idea how you want it to compare any particular two records. Did you want an alphabetical sort by name / team / position, a numerical sort by age, what? You need to choose one or more of the fields to compare to get your overall sort order. Additionally, age should probably be an integer, as should salary. Possibly rating too. |
Author: | Tallguy [ Thu Apr 23, 2009 8:26 am ] |
Post subject: | RE:records |
the user is suppose to choose which to sort from, ex if i want name then alphabtializes the name then show all the data for that name then the next user and data in alphabicital order i can't use ints they must be strings |
Author: | Nick [ Thu Apr 23, 2009 3:23 pm ] |
Post subject: | RE:records |
well adding to what DemonWasp said, you can't sort by record (i) < record (i + 1) as the compiler sees record and says "wtf is that" you need to sort by record.field (i) < record.field (i+1). how to get the right field dependant on what the user inputted, I'll leave to you |
Author: | DemonWasp [ Thu Apr 23, 2009 4:04 pm ] |
Post subject: | RE:records |
You need to manually select which way to sort based on user-interaction. So if the sort is 1 (by name) then you would use records(i).name > records(i+n).name or similar; if it's 2, then ... you get the picture. Why can't you use integers for the age? I'm confused by that. |
Author: | Tallguy [ Thu Apr 23, 2009 4:46 pm ] |
Post subject: | Re: records |
kk thanks everyone i finally got it working, i put the data within an array then sorted according to the array DemonWasp wrote: Why can't you use integers for the age? I'm confused by that. my teacher wanted us to use strings...no idea |