File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes problem with javascript sorting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "problem with javascript sorting " Watch "problem with javascript sorting " New topic

problem with javascript sorting

sirisha makkapati
Ranch Hand

Joined: Dec 10, 2006
Posts: 83
Hi to all,

I wanted add up && down icons to my theads,while sorting
my code is as follows.for ascending up arow,for descending down arow like that.
my code is as follows

<html xmlns="" xml:lang="en" lang="en">


<script language="JavaScript" type="text/javascript">

function zxcSortTable(zxcid,zxccnus){
var zxcargs=zxcSortTable.arguments
var zxctable=document.getElementById(zxcid);
var zxcrows=zxctable.rows,zxcscells=[],zxcclones=[],zxcblanks=[],zxccnt=0;
for (var zxc0=1;zxc0<zxcargs.length;zxc0++){
for (var zxc0a=1;zxc0a<zxcrows.length;zxc0a++){
var zxccells=zxcrows[zxc0a].cells;
var zxcdata=zxccells[zxcargs[zxc0]];
if (/[a-z]|[0-9]/i.test(zxcdata)){
if (!zxcrows[0].cells[zxcargs[1]].ud) zxcrows[0].cells[zxcargs[1]].ud='Up';
if (zxcrows[0].cells[zxcargs[1]].ud=='Up') zxcclones=zxcclones.reverse();
for (var zxc1=0;zxc1<zxcclones.length;zxc1++){

function zxcSortTxt(zxca,zxcb){
if (zxcaa>zxcbb) return 1;
if (zxcaa<zxcbb) return -1;
return 0;


any one please help me.
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
where did you learn to name your variables? Looking at that code gives me a headache. Go back and use descriptive variables and you will get more help. And indentation helps too. I would like to help you but I can't take the kind of time it would require to figure out those names.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Because he did not write the code...

Did you ask vwphillips about your issue?

Not sure what would be hard about it. You would have to add an image to each column and set the source

document.getElementById("sortImg" + colNumber).src = "myDirectionImage.gif";

I agree. Here's the link:
subject: problem with javascript sorting
It's not a secret anymore!