Fixed grouping routine

Key columns were not being updated when sorted, so it always grouped
based on all key columns. Added a routine to pull which columns were sorted, and match so that key columns must also be sorted columns for the grouping to occur. The demo.html file should show that the routine works