ActionScript 2.0 :: Sorting An Array Using SortOn

Feb 17, 2009

I am trying to sort an array that is generated thru an xml file.

The XML has "sections" that are used to generate a different view type, it is NOT used here but is needed for other features. What IS used is the artist name & ID. This function takes the data from XML and takes the name and ID from each section and puts it into 2 separate Arrays, "nameArr" and "noArr". After these two new arrays are created they are sent into an object "sectionData". The objects are then sent into a new Array "multiArr". This looks a little overkill but it is needed to create a new array without the section info.

I am trying to sort this new array multiArr using the "sortOn" method by "ID" to sort it by id but it is not working. It doesn't sort the array.

ActionScript Code:
public function setListData( data:Array ) {
var sectionData:Object = {};

[Code]......

View 5 Replies


Similar Posts:


ActionScript 2.0 :: SortOn(DECENDING) For The Number Array And Then Have The String Array Sort To Match

Jun 14, 2007

I have two arrays. One contains numbers and the other contains strings. I want to do a sortOn(DECENDING) for the number array and then have the string array sort to match. if my string array is

[Code]....

View 6 Replies

ActionScript 2.0 :: CS3 SortOn A NUMERIC Array

Aug 20, 2010

I have a button on the screen with the the following code attached to it's release function.

[Code]...

No matter how i sort the dataTag array it never puts the information into the respective order. The 10XXX figures always come ahead of the preceeding numerals. Anyone come across this before who can point me in the right direction?

View 10 Replies

ActionScript :: Array.sortOn() For Non-English Data?

Nov 13, 2010

this is an array of objects that i want to alphabetize:

var streets:Array = new Array();
streets.push({name:"Édouard-Montpetit"});
streets.push({name:"Alexandre de Sève"});
streets.push({name:"Van Horne"});
streets.push({name:"Atwater"});

now i'll sort my array:

streets.sortOn("name", Array.CASEINSENSITIVE);
//Sorted
Alexandre de Sève
Atwater
Van Horne
Édouard-Montpetit

the accent above the E in Édouard-Montpetit, and any other first letter with a non-english accent is sorted after Z.how i can sort this correctly? i do not have access to the named data.

View 1 Replies

ActionScript 2.0 :: Array: SortOn() Letters With Numbers?

Jan 5, 2009

I have an Array of objects that each have a Name and a Score. I can sort the Array with '.sortOn()' by the object's Name or the Score, but when I sort by the Score, if some Names have the same Score, they don't list Alphabetically within that Score.
The following code shows what I mean. The Names with a Score of 50 are together when listed by Score, but they are not Alphabetical. How do I combine both ways of sorting?

[Code]....

View 1 Replies

ActionScript 3.0 :: Flash - SortOn() Array Function?

Apr 13, 2011

I have an array of objects. The objects have a base class with various properties. Each time an object gets created, I push it into the array. However, I need to sort the objects based on one of their properties.Lets say in my object class, I have a function "ReturnNumber()" that returns a number, I want to sort my array based on which number was the highest. Can I use SortOn() to do this?

View 1 Replies

ActionScript 3.0 :: SortOn Alphanumeric Array Which Holds Objects?

Apr 7, 2010

I have an array which holds objects. The objects have properties called cat and title. The cat property can hold values like:
Cat 1
Cat 2
Cat 3

And the title property can hold values:
Title 1
Title 2
Title 3

So that you wind up with something that looks like
Cat 1
Title 1

Cat 1
Title 2

Cat 2
Title 3
etc.

Now, I want to sort these, but we all know that Array.sortOn(["cat", "title"]) will produce results like:
Cat 1
Cat 10
Cat 11
Cat 2
Cat 3

What's the most efficient method of sorting these properly (so the number component sorts like a number and not like a string)? I can request users pad their entries (yes, other people will be entering this data), but that's both a little bit ugly and not very user friendly.

View 2 Replies

ActionScript 2.0 :: Array.sortOn With String And Integer Flawed?

May 12, 2006

I'm using the sortOn method to sort my array. concider this array:

var list:Array = new Array();
list.push( {id: "1"} );
list.push( {id: "4"} );
list.push( {id: "12"} );

[code]....

How can this be fixed? I want my sort to have the following result:

fubar1, fubar4, fubar9, fubar12, fubar23

View 6 Replies

ActionScript 2.0 :: Multidimensinal Array SortOn() No Field Names?

Sep 23, 2006

My multidimensional array is created this way :

Code:
cards_array = new Array()
z=0

[code].....

View 3 Replies

ActionScript 2.0 :: Array.sortOn With Objects Of A Custom Class?

Jul 27, 2007

I'm trying to do Array.sortOn on an array of custom-class objects. It's not working, though nothing in the documentation suggests that this is a problem. Below is the code. I'm confident the MetricRecord constructor is working fine because everything else works, and the traces below are correct, except they don't sort.

// This array sorts
metricRecords = new Array();
metricRecords.push({mediaVehicle:"cca", temp:"asxcvbxcber"});
metricRecords.push({mediaVehicle:"aaa", temp:"asdfertr"});

[Code]....

View 1 Replies

Flash :: Sorting An Array So That 3 Types Of Objects Are Evenly Distributed Throughout The Array?

Oct 17, 2011

iSo let's say I have three different arrays of objects, and I want to combine them into one sorted array. I want the order to be such that the items from each array are evenly distributed throughout the sorted array.

If there were 3 xItems, 3 yItems, and 3 zItems, the sorted array would have this order: x, y, z, x, y, z, x, y, z

HOWEVER, even if the arrays are differing lengths, I still need to make them alternate as much as possible. If there were 6 xItems, 4 yItems, and 2 zItems, the sorted array should have this order: x, y, x, y, x, z, x, y, x, y, x, z

View 1 Replies

ActionScript 2.0 :: Sorting A New Array From An Existing Array?

Sep 19, 2005

i got an existing array, main[y], which after an equation, will come out with another array.

Code:
if (main[y] === topicList.getValue()){
subTopic = [];
subTopic = fTitle[y]
trace(subTopic)
}

However, i could not sort the subTopic, as it gkeep giving me undefined. Is there any way to sort this subTopic, such that they are in alphabetical orders?

View 3 Replies

ActionScript 3.0 :: Sorting An Array Based On Another Array?

Apr 10, 2012

how to reorder an array based on the information contained in another array. What my script is currently doing is detecting all the attached monitors I have and then ordering them based on their left bounds. However I then want to reorder the screens location in the array based on whether the user has selected that display or not. If the user has selected it, by clicking a button, the button movie clip will be on frame two, if they haven't been chosen it will be on frame one. So what I am doing is then creating two separate arrays, chosen screens and not chosen screens, and then combining them into one.

Code:
if(displayButton.currentFrame==displayButton.totalFrames)
{
//sort the chosen ones into an array

[Code]....

My problem now is being able to reorder a separate array which contains all the screens, called screenArray, based off of that. screenArray currently returns [Object Screen], [Object Screen], [Object Screen], etc... and is in the order of 1,2,3,4,5,6. How do I take then and get it to be equal to the order of my displayButtonsChosen Array of 1,3,5,2,4,6?

View 6 Replies

IDE :: Sorting Again Array Of Objects?

Sep 18, 2009

Trying to re-sort an array of objects from:
var arr:Array = new Array({num:0},{num:1},{num:2},{num:3})
to
var arr:Array = ({num:0},{num:3},{num:1},{num:2})

View 2 Replies

ActionScript 3.0 :: Sorting An Array Of MC's By X/y?

Mar 23, 2010

- Put a bunch of MC's on the stage distributed horizontally.

- Store them in an array.

- yourArray.sortOn("x", Array.DESCENDING)

- loop though the now "sorted" array and trace their x property.

Doesn't work, does it? If it did, shuffle them up and try again (sometimes, perhaps randomly they will be in order).

View 7 Replies

ActionScript 3.0 :: Sorting A Two Dimensional Array?

Mar 8, 2009

have a twodimensional array that consists of 6 other arrays(like array[0 to 5][0 to 4]). The [4] of each sub-array is a indexnumber that i'd like to use for sorting the array[0][x] toarray[5][x] according to their array[x][4]-value. How would I do

View 3 Replies

ActionScript 3.0 :: Sorting Array By Largest Sum?

Feb 1, 2010

How would I do to sort this array by the largest sum and not just the first number?
var myArray:Array = new Array(100, 200, 9);
myArray.sort(Array.DESCENDING)
//puts out (9, 200, 100)
How would I do to get it (200, 100, 9)?

View 1 Replies

Actionscript 3 :: Sorting An Array Of Objects?

May 23, 2010

I'm trying to sort an array of objects with ActionScript 3.

The array is like this:

var arr:Array = new Array ();
arr.push ({name:"John", date:"20080324", message:"Hi"});
arr.push ({name:"Susan", date:"20090528", message:"hello"});

can I do something with Array.sort(...) method?

View 2 Replies

Actionscript 3 :: Array Sorting According To Two Or More Values

Jun 2, 2011

How can i accomplish sorting an array according to two values. Is there built in function for that?

View 2 Replies

ActionScript 2.0 :: Sorting A Numeric Array?

Jan 9, 2009

I am loading data from an xml file into several different arrays. Once its all information is in the arrays I then sort one of the arrays (called percentage) numerically from highest to lowest. What I can't figure out is how to reflect the changes in position in the other arrays to what has happened in the percentage array.

View 6 Replies

ActionScript 3.0 :: Sorting An Array Which May Contain Nulls

Aug 11, 2009

I'm using Insertion sort on a partially sorted array:

ActionScript Code:
for(i=0;i<productArray.length;i++)
{
var val:Product = productArray[i];

[Code].....

The problem is that since products are removed from time to time, my array may contain null references for some indexes. Thus the above algorithm will throw an error in runtime.

Usually I'd just do a quick check i.e.

if(productArray[i] != null)

and I'd be fine, but in this case I'm constantly checking properties in the while loop and I'm not really sure how to go about doing this.

View 2 Replies

ActionScript 3.0 :: Sorting Names In An Array?

Nov 22, 2010

I want this to be sorted by first name only: "John Smith 18", "Charlotte Smith 59", "Chris Doe 26", "Tony Jordan 100", "Charlotte Roberts 17", "Imad Hanna 26", "Charlotte Smith 13"

I can get it sort sort alphabetically just by using .sort(), but it takes into account the last name as well.

View 4 Replies

ActionScript 3.0 :: Sorting Xml Data Into Array?

Mar 2, 2011

I am creating a visual map in flash of my database bookings table. I have my xml loaded into AS3 and I think that the next stage is to sort the data by the room numbers and place the data into separate arrays, how do I approach this?

View 4 Replies

Actionscript 3.0 :: Multi-Dim Array Sorting?

Jul 25, 2010

I think im missing something really simple here. I'm just trying to sort a multidimensional array.

Code: Select allvar array:Array = new Array();
var num1:Number = 10;
var num2:Number = 20;

[code].....

View 3 Replies

ActionScript 2.0 :: Sorting Multidimensional Array?

May 25, 2004

I have an array of objects (the first member of each object is a string which records the object's name) The other members of the objects contain various numerical information. I need to sort each category of information and display the names next to their related information in correct numerical order:

ie. AName 4235
AnotherOne 3962
OneMore 1576

Can anyone suggest some code which would do this? I checked out .sort and .onSort, built in methods of array but I can't get my head round it.There are thirteen objects in my array. The fourth element (population) needs to be sorted.

[Code]...

View 3 Replies

ActionScript 2.0 :: Sorting A MultiDimension Array OOP, FP7?

Dec 26, 2005

I have a function inside a class that will basically sort an array by the first elements first sub-element (ie. [0][x]) and return the second sub element based on that information. I am having the hardest time getting it to work. Partially because I feel that it is inside a class. Also I feel like it sorts the sub elements individually whereas I would need to keep the sub-element pairs together. Here is some of the code.

[Code]...

View 4 Replies

ActionScript 3.0 :: Sorting A Multidimensional Array

Jan 14, 2010

I have a multidimensional array that looks like this:[code]what I am trying to do is sort the mc.names into order based on what the value of Tracker[mc.name][0] is. (if that makes sense)I am looking at the : SampleArray.sortOn("0",Array.NUMERIC); but it doesnt seem to work as I had hoped, so im not sure if im doing something wrong or just not understanding how it works etc.I just need the mc.name's to be reordered into the numerical order from the numbers in the[0] and keep the right mc.name with the numbers.

View 4 Replies

ActionScript 2.0 :: Sorting Images In Array?

Oct 16, 2002

i've placed some photographs in array...and now I want to sort them into sets such as "album1", "album2"....how do i do this?

View 1 Replies

Flash - AS3 Numerical Array Sorting In Order?

Jul 9, 2011

var dataArray:Array = [ 5, 6, 3, 8, 10, 11, 32, 2 ];
var dataObjectArray:Array [ { "uid": 5 }, { "uid": 6 .... Similar to above ... } ];
I have the above 2 arrays in AS3. and i wish to sort them numerically (1 ~ X) in order [Skipping those that does not exist]. What is the best and most efficient way to do so for dataArray / dataObjectArray.

View 2 Replies

AS3 :: Flash - Sorting An Array Of Nested Arrays?

Nov 4, 2011

How would I go about sorting an array of nested arrays, based on the contents of one of the nested arrays elements?

var nestedArray1:Array = new Array(0,0,1);
var nestedArray2:Array = new Array(0,0,9);
var nestedArray3:Array = new Array(0,0,7);

[code].....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved