Avatar ·

Python, How to sort a list based on another list?

📁 Advanced Python Topics

box_b = [7, 3, 9, 5]box_a = [apple, banana, cherry, lemon]

The idea is that after sorting box_b, I need box_a sorted in the same way.

# after sorting box_b and some algorithm*box_b = [3, 5, 7, 9]box_a = [banana, lemon, apple, cherry]
Avatar ·

To complete the picture, an answer with

import loggingimport inotify.adapters_DEFAULT_LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'_LOGGER = logging.getLogger(__name__)def _configure_logging():    _LOGGER.setLevel(logging.DEBUG)    ch = logging.StreamHandler()    formatter = logging.Formatter(_DEFAULT_LOG_FORMAT)    ch.setFormatter(formatter)    _LOGGER.addHandler(ch)def _main():    i = inotify.adapters.Inotify()    i.add_watch('/tmp')    try:        for event in i.event_gen(                                

Log in to leave an answer

Blogs