(function($){
	$.fn.accessKeys = function(options) {  
		// Function written by Paul Evans.
		$this = $(this);
		$('a[accesskey]').each(function(i) {
			$this.append('<div>Access Key \'' + $(this).attr('accesskey') + '\' - ' + $(this).text() + '</div>');
			var rows = $this.find('div').get();
			rows.sort(function(a, b) {
				var keyA = $(a).text().toUpperCase();
				var keyB = $(b).text().toUpperCase();
				if (keyA < keyB) return -1;
				if (keyA > keyB) return 1;
				return 0
			})
			$.each(rows, function(index, row) {
				$this.append(row);
			})
		});
		return this;
	};
})(jQuery);

$(document).ready(function(){
	$('#keylist').accessKeys();
});

