Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #19552
| From | "Tony" <tony.johansson@inport.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | About keeping my array 1 based after having sorted it |
| Date | 2013-05-01 17:18 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <klrbhd$duk$1@dont-email.me> (permalink) |
I use a 1 based array because I need to find each record that is a multiple
of three later in the code.
After I have used this sort below the array is then back to use zero based.
I can handle this in his way
for (var i = 0; i < bookingArray.length; i++)
{
a[++j] = bookingArray[i];
}
bookingArray = a;
but I just wonder if I can make the sort to keep my 1 based array ?
bookingArray.sort(function (a, b)
{
var aObjectid = a.Objectid;
var bObjectid = b.Objectid;
var aFromtime = new Date(a.Fromtime);
var bFromtime = new Date(b.Fromtime);
if (aObjectid == bObjectid)
return (aFromtime < bFromtime) ? -1 : (aFromtime
> bFromtime) ? 1 : 0;
else
return (aObjectid < bObjectid) ? -1 : 1;
});
//Tony
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
About keeping my array 1 based after having sorted it "Tony" <tony.johansson@inport.com> - 2013-05-01 17:18 +0200
Re: About keeping my array 1 based after having sorted it Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-01 08:26 -0700
Re: About keeping my array 1 based after having sorted it "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-01 19:43 +0200
Re: About keeping my array 1 based after having sorted it Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-01 15:15 -0700
Re: About keeping my array 1 based after having sorted it "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-02 09:35 +0200
Re: About keeping my array 1 based after having sorted it Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-02 14:31 +0000
Re: About keeping my array 1 based after having sorted it Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-01 22:12 +0000
Re: About keeping my array 1 based after having sorted it "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-02 09:36 +0200
Re: About keeping my array 1 based after having sorted it Scott Sauyet <scott.sauyet@gmail.com> - 2013-05-02 08:52 -0700
Re: About keeping my array 1 based after having sorted it Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-03 01:26 +0200
Re: About keeping my array 1 based after having sorted it Scott Sauyet <scott.sauyet@gmail.com> - 2013-05-03 08:53 -0700
Re: About keeping my array 1 based after having sorted it Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-03 18:39 +0200
Re: About keeping my array 1 based after having sorted it Scott Sauyet <scott.sauyet@gmail.com> - 2013-05-03 11:00 -0700
Sorting arrays of objects (was: About keeping my array 1 based after having sorted it) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-05 01:00 +0200
Re: Sorting arrays of objects (was: About keeping my array 1 based after having sorted it) Scott Sauyet <scott.sauyet@gmail.com> - 2013-05-05 08:53 -0700
Re: About keeping my array 1 based after having sorted it Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-05-04 16:14 +0100
csiph-web