'''simple docstring'''

import operator







def __UpperCamelCase(   _A					:				str  ,			_A					:				Tuple = False  ,			_A					:				List[Any] = None    ):
   '''simple docstring'''
   UpperCAmelCase__							:				Union[str, Any]   				=  operator.lt if reverse else operator.gt
   UpperCAmelCase__							:				List[str]   				=  solution or []

   if not arr:
      return solution

   UpperCAmelCase__							:				Tuple   				=  [arr.pop(0    )]
   for i, item in enumerate(lowerCamelCase_    ):
      if _operator(lowerCamelCase_  ,			sublist[-1]    ):
         sublist.append(lowerCamelCase_    )
         arr.pop(lowerCamelCase_    )

    #  merging sublist into solution list
   if not solution:
      solution.extend(lowerCamelCase_    )
   else:
      while sublist:
         UpperCAmelCase__							:				List[Any]   				=  sublist.pop(0    )
         for i, xx in enumerate(lowerCamelCase_    ):
            if not _operator(lowerCamelCase_  ,			lowerCamelCase_    ):
               solution.insert(lowerCamelCase_  ,			lowerCamelCase_    )
               break
         else:
            solution.append(lowerCamelCase_    )

   strand_sort(lowerCamelCase_  ,			lowerCamelCase_  ,			lowerCamelCase_    )
   return solution


if __name__ == "__main__":
      assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
      assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]





'''simple docstring'''

from __future__ import annotations

import sys
from collections import deque
from typing import Generic, TypeVar

UpperCamelCase__     :	Tuple				=			TypeVar('T')


class 				_lowercase	(      Generic[T]   ):
      '''simple docstring'''


      UpperCAmelCase_      :      deque[T]  # Cache store of keys
      UpperCAmelCase_      :      set[T]  # References of the keys in cache
      UpperCAmelCase_      :      int      							=   10  # Maximum capacity of cache




      def __init__(				self					,lowerCamelCase_							)			->			None:



         '''simple docstring'''



         UpperCAmelCase__							:				Any   				=  deque()
         UpperCAmelCase__							:				Optional[int]   				=  set()
         if not n:
            UpperCAmelCase__							:				List[Any]   				=  sys.maxsize
         elif n < 0:
            raise ValueError('''n should be an integer greater than 0.'''							)
         else:
            UpperCAmelCase__							:				Any   				=  n




      def 		lowerCAmelCase__					(				self					,lowerCamelCase_							)			->			None:



         '''simple docstring'''



         if x not in self.key_reference:
            if len(self.dq_store							) == LRUCache._MAX_CAPACITY:
               UpperCAmelCase__							:				int   				=  self.dq_store.pop()
               self.key_reference.remove(lowerCamelCase_							)
         else:
            self.dq_store.remove(lowerCamelCase_							)

         self.dq_store.appendleft(lowerCamelCase_							)
         self.key_reference.add(lowerCamelCase_							)




      def 		lowerCAmelCase__					(				self							)			->			None:



         '''simple docstring'''



         for k in self.dq_store:
            print(lowerCamelCase_							)




      def __repr__(				self							)			->			str:



         '''simple docstring'''



         return f'''LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store							)}'''


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  UpperCamelCase__     :	LRUCache[str | int]				=			LRUCache(4)
  lru_cache.refer('A')
  lru_cache.refer(2)
  lru_cache.refer(3)
  lru_cache.refer('A')
  lru_cache.refer(4)
  lru_cache.refer(5)
  lru_cache.display()

  print(lru_cache)
  assert str(lru_cache) == "LRUCache(4) => [5, 4, 'A', 3]"




