473,386 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sorting two dimentional array and displaying result

Expand|Select|Wrap|Line Numbers
  1. function abc()
  2. {
  3.     var tstr1 = new Array();
  4.     var vari=50;
  5.     var htmlText  ='';
  6.  
  7.         for(var i=0; i<vari; i++)
  8.         {
  9.             tstr1.push(["a" + i, "second value" + i]);
  10.         }
  11.  
  12.                     tstr1.sort(function(a, b) 
  13.                                 {    //sorting first value in alphabetical order and the associated value
  14.                                   return a[0] < b[0]
  15.                                     ? -1
  16.                                     : a[0] == b[0]
  17.                                       ? 0
  18.                                       : 1
  19.                                     ;
  20.                                 }
  21.                             );
  22.  
  23.  
  24.                     for(var t=0; t<tstr1.length; t++)
  25.                     {
  26.                         //creating html to display value1 and value 2
  27.                         htmlText = htmlText + "<li>" + tstr1[t][0] +"----------" + tstr1[t][1] +"</li>";
  28.                     }
  29.                     htmlText = "<ul>" + htmlText + "</ul>";
  30.                     document.write(htmlText);
  31.  
  32. }
Feb 6 '09 #1
1 1579
Dormilich
8,658 Expert Mod 8TB
and what exactly is the problem?
Feb 6 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Cedric Baelemans | last post by:
Hi, I try to store a two-dimentional array in a session variable. When I do the same with a one-dimentional array, it works fine, but with a two-dimentional array it fails. Is this not possible?...
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
8
by: guitarromantic | last post by:
Hey, I have a 'staff' table with a column 'status', corresponding to a 'statuses' table with the appropriate titles (eg 1 | Editor in Chief). I want to display on the page the headings (the...
2
by: Alan Searle | last post by:
I find that I can display structured data very nicely using XML with an XSL template. As an extra 'goodie', I would like to give users the ability to sort that data (for example with a button...
0
by: Max M. Power | last post by:
I'm getting an InvalidOperationException calling Invoke with a method parameter object array that contains a two dimentional string array. More stack trace output below: // Create two...
5
by: Nel | last post by:
Hi all, I am using php and mysql to search through a database of stores for the nearest store to a given postcode. I have managed to limit the selection to the nearest stores (roughly within...
9
by: Srinu | last post by:
Hi All, We know the following facts, 1. A two dimentional arrays in C is stored similar to a single dimentional array. 2. * is the dereference operator that gives value at address denoted by...
4
by: Tobiah | last post by:
Imagine an excel spreadsheet. I can choose a column and sort the records based on the items in that column. I would like to do the same thing with a large two dimensional array. What would be...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.