View Single Post
Old 02-28-2013, 05:07 AM   PM User | #2
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,765
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
Lightbulb

You array initialization is incorrect.
See the following test to demonstrate the problems and the comments about them.

Note: This does not address the sort problem because your initial premiss is wrong.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> Untitled </title>
</head>
<body>

<script type="text/javascript">
var tarr = { q:2, q:1, q:3 };
for (var key in tarr) { alert(key+' : '+tarr[key]); }  // results in only the last entry displayed

var tarr = { qa:2, qb:1, qc:3 };
for (var key in tarr) { alert(key+' : '+tarr[key]); }  // resultes in 3 entries displayed

</script>

</body>
</html>
jmrker is offline   Reply With Quote