[Xerte] Re-indexing an array

Dave Burnett d_b_burnett at hotmail.com
Tue Oct 26 14:22:31 BST 2010


Think I bumbled across it:

   
    myArray.unshift(myArray[i]); // when condition in loop matches, copy to start of array (unshift inserts at start)
    myArray.deleteAtIndex(i+1); //delete at matched index (add 1 because you inserted 1 at front)





> From: Patrick.Lockley at nottingham.ac.uk
> To: xerte at lists.nottingham.ac.uk
> Date: Tue, 26 Oct 2010 13:54:21 +0100
> Subject: RE: [Xerte] Re-indexing an array
> 
> Slicing? Splicing? 
> 
> Array to string. Remove that entry. Add it to the beginning. String to array?
> ________________________________________
> From: xerte-bounces at lists.nottingham.ac.uk [xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett [d_b_burnett at hotmail.com]
> Sent: Tuesday, October 26, 2010 1:18 PM
> To: Xerte list
> Subject: [Xerte] Re-indexing an array
> 
> What's the most elegant way to promote an array item?
> 
> I have a 2 dimensional array of items.
> I loop through those, and when a specific set of criteria matches, want to promote that to index [0]
> 
> Cheers,
> 
> Dave
> _______________________________________________
> Xerte mailing list
> Xerte at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
> This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
> 
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20101026/cf36fce1/attachment.html


More information about the Xerte mailing list