Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Ordering Data?

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
10-19-2006 12:27
I have a data set of 4 "objects" and each object has 2 values assigned to them (lets call them a and b). how would I go about ordering this data so that it sorts by value of a, and then by value of b. example:


data set:

Object1(4,5)
Object2(-3,2)
Object3(4,-1)
Object4(1,0)


how it would be organized greatest to least:

Object1(4,5)
Object3(4,-1)
Object4(1,0)
Object2(-3,2)
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Dragnar Drake
Registered User
Join date: 6 Feb 2006
Posts: 25
10-19-2006 12:51
well what kind of data are you trying to move? vector, integer, string, ect?

integer would be easy, vector a little harder, float about the same as integer,

string would be kind of hard since then i believe you'll be going into binory*SP* when it comes into order from greatest to least.

so please tell use what kind of data you want moved
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
10-19-2006 13:14
From: Dragnar Drake
well what kind of data are you trying to move? vector, integer, string, ect?

integer would be easy, vector a little harder, float about the same as integer,

string would be kind of hard since then i believe you'll be going into binory*SP* when it comes into order from greatest to least.

so please tell use what kind of data you want moved


all the data is integer/float.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
10-19-2006 15:21
If you are talking about a limited set of items then a simple bubble sort would do.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-19-2006 16:12
From: Newgate Ludd
If you are talking about a limited set of items then a simple bubble sort would do.


What is simple for some is......................... LOL. Please cast some of your knowledge my way. I had been thinking about Senuka's problem off and on for a couple of hours. Sorting "Object#" would be easy, everything in a list and just do a strided sort, up or down. But then it gets complicated for me when trying to sort the second or third fields.

I know if I beat myself up for a couple of hours I could come up with a really ugly way to do it and it would work. Then after thinking and looking at my solution for a couple more days I could see a more elegant way to do it. But since I don't really need this solution for anythign I am currently working on I will be lazy and ask to see a demo script of this :-)
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
10-19-2006 23:51
From: Jesse Barnett
What is simple for some is......................... LOL. Please cast some of your knowledge my way. I had been thinking about Senuka's problem off and on for a couple of hours. Sorting "Object#" would be easy, everything in a list and just do a strided sort, up or down. But then it gets complicated for me when trying to sort the second or third fields.

I know if I beat myself up for a couple of hours I could come up with a really ugly way to do it and it would work. Then after thinking and looking at my solution for a couple more days I could see a more elegant way to do it. But since I don't really need this solution for anythign I am currently working on I will be lazy and ask to see a demo script of this :-)


lol, that's been my exact thoughts. my data set is actually 16 Objects with about 3-4 data points for each, but I figured if someone could help me out with a simple 4 & 2, I could model a sorting system for my data off of that.

I come from an almost pure mathematical background with little to no comp science, and have no idea what a "bubble sort" is.

[edit]
I was also contemplating storing the data points for each object as a list:

example:
list object1 ["name1",a,b]

as opposed to my current storage method:

integer object1a=a;
integer object1b=b;
string object1="name1";
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
10-20-2006 00:37
Google is your friend!

http://en.wikipedia.org/wiki/Bubble_sort
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
10-20-2006 00:58
Beat me to it Squirrel :)

Bubblesorts are probably the easiest sort to implement. I'd suggest using lists, or strided lists if you like them :), its more effiecient if you suddenly have to cater for say 20 objects rather than 16 as you dont need to recode.