docs: def storage_soc_sorted(network, filename = None):
      """
      Plots the soc (state-pf-charge) of extendable storages
      
      Parameters
      ----------
      network : PyPSA network container
          Holds topology of grid including results from powerflow analysis
  
      filename : path to folder
      
      """
      sbatt = network.storage_units.index[(network.storage_units.p_nom_opt>1) &
                                      (network.storage_units.capital_cost>10) & 
                                      (network.storage_units.max_hours==6)]
      shydr = network.storage_units.index[(network.storage_units.p_nom_opt>1) &
                                      (network.storage_units.capital_cost>10)
                                      & (network.storage_units.max_hours==168)]
  
      cap_batt = (network.storage_units.max_hours[sbatt] * 
                  network.storage_units.p_nom_opt[sbatt]).sum()
      cap_hydr = (network.storage_units.max_hours[shydr] *
                  network.storage_units.p_nom_opt[shydr]).sum()
  
      fig, ax = plt.subplots(1, 1)
  
      if network.storage_units.p_nom_opt[sbatt].sum() < 1 and \
          network.storage_units.p_nom_opt[shydr].sum() < 1:
          print("No storage unit to plot")
      elif network.storage_units.p_nom_opt[sbatt].sum() > 1 and \
          network.storage_units.p_nom_opt[shydr].sum() < 1:
          (network.storage_units_t.p[sbatt].sum(axis=1).sort_values(
                  ascending=False).reset_index() / \
          network.storage_units.p_nom_opt[sbatt].sum())[0].plot(
                  ax=ax, label="Battery storage", color='orangered')
      elif network.storage_units.p_nom_opt[sbatt].sum() < 1 and \
          network.storage_units.p_nom_opt[shydr].sum() > 1:
          (network.storage_units_t.p[shydr].sum(axis=1).sort_values(
                  ascending=False).reset_index() / \
          network.storage_units.p_nom_opt[shydr].sum())[0].plot(
                  ax=ax, label="Hydrogen storage", color='teal')
      else:
          (network.storage_units_t.p[sbatt].sum(axis=1).sort_values(
                  ascending=False).reset_index() / \
          network.storage_units.p_nom_opt[sbatt].sum())[0].plot(
                  ax=ax, label="Battery storage", color='orangered')
          (network.storage_units_t.p[shydr].sum(axis=1).sort_values(
                  ascending=False).reset_index() / \
          network.storage_units.p_nom_opt[shydr].sum())[0].plot(
                  ax=ax, label="Hydrogen storage", color='teal')
  
      ax.set_xlabel("")
      ax.set_ylabel("Storage dispatch in p.u. \n <- charge - discharge ->")
      ax.set_ylim([-1.05,1.05])
      ax.legend()
      ax.set_title("Sorted duration curve of storage dispatch")
  
      if filename is None:
          plt.show()
      else:
          plt.savefig(filename,figsize=(3,4),bbox_inches='tight')
          plt.close()
  
      return