SHARE
TWEET

Natural sorting of file names

themoosemind Jul 17th, 2014 724 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. >>> tables
  2. ['wm_raw_draw_data_11.sql', 'wm_similarity.sql', 'wm_renderings.sql', 'wm_raw_draw_data_6.sql', 'wm_raw_draw_data_1.sql', 'wm_raw_draw_data_14.sql', 'wm_raw_draw_data_15.sql', 'wm_raw_draw_data_5.sql', 'wm_raw_draw_data_12.sql', 'wm_raw_draw_data_10.sql', 'wm_raw_draw_data_9.sql', 'wm_raw_draw_data_3.sql', 'wm_challenges.sql', 'wm_votes.sql', 'wm_raw_draw_data_13.sql', 'wm_raw_draw_data_4.sql', 'wm_workers.sql', 'wm_languages.sql', 'wm_formula2challenge.sql', 'wm_raw_draw_data_8.sql', 'wm_raw_draw_data_16.sql', 'wm_raw_draw_data_7.sql', 'wm_formula_svg_missing.sql', 'wm_raw_data2formula.sql', 'wm_raw_draw_data_2.sql', 'wm_invalid_formula_requests.sql', 'wm_raw_draw_data_17.sql', 'wm_user_unknown_formula.sql', 'wm_formula.sql', 'wm_users.sql.gz', 'wm_worker_answers.sql.gz']
  3.  
  4. >>> import natsort
  5. >>> natsort.natsorted(tables)
  6. ['wm_challenges.sql', 'wm_formula2challenge.sql', 'wm_formula.sql', 'wm_formula_svg_missing.sql', 'wm_invalid_formula_requests.sql', 'wm_languages.sql', 'wm_raw_data2formula.sql', 'wm_raw_draw_data_1.sql', 'wm_raw_draw_data_2.sql', 'wm_raw_draw_data_3.sql', 'wm_raw_draw_data_4.sql', 'wm_raw_draw_data_5.sql', 'wm_raw_draw_data_6.sql', 'wm_raw_draw_data_7.sql', 'wm_raw_draw_data_8.sql', 'wm_raw_draw_data_9.sql', 'wm_raw_draw_data_10.sql', 'wm_raw_draw_data_11.sql', 'wm_raw_draw_data_12.sql', 'wm_raw_draw_data_13.sql', 'wm_raw_draw_data_14.sql', 'wm_raw_draw_data_15.sql', 'wm_raw_draw_data_16.sql', 'wm_raw_draw_data_17.sql', 'wm_renderings.sql', 'wm_similarity.sql', 'wm_user_unknown_formula.sql', 'wm_users.sql.gz', 'wm_votes.sql', 'wm_worker_answers.sql.gz', 'wm_workers.sql']
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top