44 'maybe_open' , 'image_size' , 'bunzip' , 'join_path_file' , 'loads' , 'loads_multi' , 'untar_dir' , 'repo_details' ,
55 'run' , 'open_file' , 'save_pickle' , 'load_pickle' , 'truncstr' , 'spark_chars' , 'sparkline' , 'autostart' ,
66 'EventTimer' , 'stringfmt_names' , 'PartialFormatter' , 'partial_format' , 'utc2local' , 'local2utc' , 'trace' ,
7- 'round_multiple' , 'modified_env' , 'ContextManagers' , 'str2bool' ]
7+ 'round_multiple' , 'modified_env' , 'ContextManagers' , 'str2bool' , 'sort_by_run' ]
88
99# Cell
1010from .imports import *
@@ -368,4 +368,16 @@ def __exit__(self, *args, **kwargs): self.stack.__exit__(*args, **kwargs)
368368def str2bool (s ):
369369 "Case-insensitive convert string `s` too a bool (`y`,`yes`,`t`,`true`,`on`,`1`->`True`)"
370370 if not isinstance (s ,str ): return bool (s )
371- return bool (distutils .util .strtobool (s )) if s else False
371+ return bool (distutils .util .strtobool (s )) if s else False
372+
373+ # Cell
374+ def sort_by_run (fs ):
375+ end = L (fs ).attrgot ('toward_end' )
376+ inp ,res = L (fs )[~ end ] + L (fs )[end ], L ()
377+ while len (inp ):
378+ for i ,o in enumerate (inp ):
379+ if _is_first (o , inp ):
380+ res .append (inp .pop (i ))
381+ break
382+ else : raise Exception ("Impossible to sort" )
383+ return res
0 commit comments