added partial sorting and converted tabs to spaces