class_docstr: Class to provide helper functions for mathematics and other small things
class_docstr_tok: ["Class","to","provide","helper","functions","for","mathematics","and","other","small","things"]
docstr: Sorts the probability table.
  
  Sorts a dictionary of dictionaries (and all the sub-dictionaries).
  
  Args:
      prob_table -> The probability table returned by the neural network to sort.
  
  Returns:
      Returns the prob_table, but sorted.
docstr_tok: ["Sorts","the","probability","table",".","Sorts","a","dictionary","of","dictionaries","(","and","all","the","sub-dictionaries",")",".","Args",":","prob_table","-",">","The","probability","table","returned","by","the","neural","network","to","sort",".","Returns",":","Returns","the","prob_table",",","but","sorted","."]
code: def sort_prob_table(self, prob_table: dict) -> dict:
      """Sorts the probability table.
  
      Sorts a dictionary of dictionaries (and all the sub-dictionaries).
  
      Args:
          prob_table -> The probability table returned by the neural network to sort.
  
      Returns:
          Returns the prob_table, but sorted.
  
      """
      # for each object: prob table in dictionary
      max_overall: int = 0
      max_dict_pair: dict = {}
      highest_key = None
      empty_dict: dict = {}
      # sorts the prob table before we find max, and converts it to order dicts
      for key, value in prob_table.items():
          prob_table[key] = self.new_sort(value)
          prob_table[key] = dict(prob_table[key])
  
      # gets maximum key then sets it to the front
      counter_max: int = 0
      counter_prob: int = len(prob_table)
      while counter_max < counter_prob:
          max_overall = 0
          highest_key = None
          logging.debug(
              f"Running while loop in sort_prob_table, counterMax is {counter_max}"
          )
          for key, value in prob_table.items():
              logging.debug(f"Sorting {key}")
              maxLocal = 0
              # for each item in that table
              for key2, value2 in value.items():
                  logging.debug(
                      f"Running key2 {key2}, value2 {value2} for loop for {value.items()}"
                  )
                  maxLocal = maxLocal + value2
                  logging.debug(
                      f"MaxLocal is {maxLocal} and maxOverall is {max_overall}"
                  )
                  if maxLocal > max_overall:
                      logging.debug(f"New max local found {maxLocal}")
                      # because the dict doesn't reset
                      max_dict_pair = {}
                      max_overall = maxLocal
                      # so eventually, we get the maximum dict pairing?
                      max_dict_pair[key] = value
                      highest_key = key
                      logging.debug(f"Highest key is {highest_key}")
              # removes the highest key from the prob table
          logging.debug(
              f"Prob table is {prob_table} and highest key is {highest_key}"
          )
          logging.debug(f"Removing {prob_table[highest_key]}")
          del prob_table[highest_key]
          logging.debug(f"Prob table after deletion is {prob_table}")
          counter_max += 1
          empty_dict = {**empty_dict, **max_dict_pair}
  
      # returns the max dict (at the start) with the prob table
      # this way, it should always work on most likely first.
      logging.debug(
          f"The prob table is {prob_table} and the maxDictPair is {max_dict_pair}"
      )
      logging.debug(f"The new sorted prob table is {empty_dict}")
      return empty_dict
  
file_path: Ciphey/ciphey/mathsHelper.py
imports: from collections import OrderedDict
  from string import punctuation
  from typing import Optional
  import logging
  from rich.logging import RichHandler
label_desc: Use image node_id 5 for calling the mathsHelper obj's underlying member method code with example usage: obj.sort_prob_table(prob_table) and returns: empty_dict