Advertisement
themoosemind

Natural sorting of file names

Jul 17th, 2014
1,804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  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']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement