JS Table Sorting for BBC Glow – v1.3 (Updated)

6

Posted by Rob | Posted in BBC Glow, Code, Javascript | Posted on 01-04-2010

Tags: , , ,

Morning all, I’ve recently started working for the BBC, and as such I’ve started working with the internal JavaScript framework, Glow.

So this is my first attempt at writing to some code with it. I hope it’s useful to someone. It’s just a simple JavaScript table sort.

The Introduction

Just a bit of useful script for client side sorting of tables. Simple click the headers of the columns, and it will arrange it in ascending order. A second click will arrange it in descending order.

As Seen On…

BBC News Common-Wealth Games Medals Table : In English, In Urdu, In Hindi, and on BBC Worldwide

UPDATE – 30th July 2010: After talking with a BBC colleague, it occurred to me that I could improve the code, so that it doesn’t rely on the class names for the ordering. The class names are now purely for decoration, not functionality.

UPDATE 2 – 30th July 2010: It was just pointed out by James (thanks man), that Glow/JS doesn’t handle number sorting brilliantly, so I’ve added a small patch to improve this. Thanks to James for his suggestion.

UPDATE 3 – 3rd August 2010: Some alterations to improve sorting of floats.

Read the rest of this entry »