I have used uniq -c and sort extensively on other machines, and it always worked very well.Now, on my new Ubuntu (13.04) machine, I end up with a weird ordering:% cat queries.log | grep INSERT | sort | uniq -c | sort      1 INSERT INTO A (id, organization_id) VALUES (?, ?)      2 INSERT INTO B (id, resource_id) VALUES (?, ?)      2 INSERT INTO C (id) VALUES (?)      2 INSERT INTO D (email, password) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)      3 INSERT INTO E (user_id, type) VALUES (?, ?)  40275 INSERT INTO F (id, resource_id) VALUES (?, ?)  40283 INSERT INTO G (action_id, role_id, user_id) VALUES (?, ?, ?, ?, ?)      6 INSERT INTO H (id, resource_id) VALUES (?, ?)Why is 6 after 40283?And how can I end up with the expected natural order?
Sort doesn't use natural order
sort;uniq
You need to supply the -n option to enable numerical sort,   -n, --numeric-sort          compare according to string numerical value