This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Engineering
»
HTML, CSS and JavaScript
Author
output of this code
Rajesh Veluchamy
Ranch Hand
Joined: Jan 15, 2008
Posts: 47
posted
Jan 22, 2008 23:51:00
0
can you say what is happening in this program(sort jsp).........
the comment line is written by me
<html> <body> <script type="text/javascript"> var c = 0; function sortNumber(a, b) { c = c+1; document.write(a + " " + b+ " " + "<br>");//written by me to check the value of a & b return a - b; } var arr = new Array(6); arr[0] = "10"; arr[1] = "5"; arr[2] = "40"; arr[3] = "25"; arr[4] = "1000"; arr[5] = "1"; document.write(arr + "<br><br>"); document.write("<br>" + arr.sort(sortNumber)); </script> </body> </html>
output:
10,5,40,25,1000,1
5 1000
40 25
10 40
40 1000
1 1000
1 5
40 5
10 25
1 25
25 5
1 10
10 5
5 1
1,5,10,25,40,1000
-Rajesh.v
Software Consultant (IT)
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
Jan 23, 2008 06:58:00
0
I am not sure what you are after here....It goes through the array and sorts the number. The output shows how the sort works.
Eric
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: output of this code
Similar Threads
while-loop
new to JavaScript but got Probs
how to encrypt the text
JavaScript code question
Help with displaying data properly
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter