Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19582

Re: About keeping my array 1 based after having sorted it

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: About keeping my array 1 based after having sorted it
Date 2013-05-02 14:31 +0000
Organization A noiseless patient Spider
Message-ID <klttcq$m0v$2@dont-email.me> (permalink)
References <klrbhd$duk$1@dont-email.me> <guagt.23460$zH4.10295@newsfe13.iad> <XnsA1B3C892E7F06eejj99@194.109.133.133> <Jtggt.32252$2b6.23400@newsfe10.iad> <XnsA1B4618E3BD9eejj99@194.109.133.133>

Show all headers | View raw


On Thu, 02 May 2013 09:35:24 +0200, Evertjan. wrote:

> The above 3/ shows the weakness in the OQ specification of the need for
> a 1-based array:

Indeed, the OP might be better off using an array of objects, where each 
object contained 3 values, and he could:

function booking( a, b ) {
  this.a = a; this.b = b; this.c = 0;
}

function make_booking( a, b, bookings ) {
  bookings.push( new booking( a, b ) );
  return bookings;
}

function some_function( x, y ) {
  var z;
  /* code goes here */
  return z;
}

function update_bookings( bookings ) {
  var i;
  for ( i = 0; i < bookings.length; i++ )
    if ( bookings[i].c == 0 )
      bookings[i].c = some_function( bookings[i].a, bookings[i].b );
  return bookings;
}

Of course, that code will get horribly distorted now, but whatever ;)

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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