fixes from running unit tests on Matlab
symvar improvements, sorting works to match matlab (new implementation), fixes bug #24

dropped the old sorting code which wasn't portable to matlab anyway