import os
import json

from kitchen.settings import KITCHEN_LOCATION

def load_data(data_type):
    retval = {}
    nodes_dir = os.path.join(KITCHEN_LOCATION, data_type)
    if not os.path.isdir(nodes_dir):
        raise IOError('Invalid data type or kitchen location. Check your settings.')
    for filename in os.listdir(nodes_dir):
        if filename.endswith('.json'):
            f = open(os.path.join(nodes_dir, filename), 'r')
            retval[filename[:-5]] = json.load(f)
            f.close()
    return retval


import os
import json

from kitchen.settings import KITCHEN_LOCATION

def load_data(data_type):
    retval = []
    nodes_dir = os.path.join(KITCHEN_LOCATION, data_type)
    if not os.path.isdir(nodes_dir):
        raise IOError('Invalid data type or kitchen location. Check your settings.')
    for filename in os.listdir(nodes_dir):
        if filename.endswith('.json'):
            entry = {'name': filename[:-5]}
            f = open(os.path.join(nodes_dir, filename), 'r')
            entry['data'] = json.load(f)
            f.close()
            retval.append(entry)
    return retval


Use a sortable list instead of a dictionary of values for the return value
Use a sortable list instead of a dictionary of values for the return value

  import os
  import json
  
  from kitchen.settings import KITCHEN_LOCATION
  
  def load_data(data_type):
-     retval = {}
+     retval = []
      nodes_dir = os.path.join(KITCHEN_LOCATION, data_type)
      if not os.path.isdir(nodes_dir):
          raise IOError('Invalid data type or kitchen location. Check your settings.')
      for filename in os.listdir(nodes_dir):
          if filename.endswith('.json'):
+             entry = {'name': filename[:-5]}
              f = open(os.path.join(nodes_dir, filename), 'r')
-             retval[filename[:-5]] = json.load(f)
+             entry['data'] = json.load(f)
              f.close()
+             retval.append(entry)
      return retval
  
  
Use a sortable list instead of a dictionary of values for the return value
## Code Before:
import os
import json

from kitchen.settings import KITCHEN_LOCATION

def load_data(data_type):
    retval = {}
    nodes_dir = os.path.join(KITCHEN_LOCATION, data_type)
    if not os.path.isdir(nodes_dir):
        raise IOError('Invalid data type or kitchen location. Check your settings.')
    for filename in os.listdir(nodes_dir):
        if filename.endswith('.json'):
            f = open(os.path.join(nodes_dir, filename), 'r')
            retval[filename[:-5]] = json.load(f)
            f.close()
    return retval


## Instruction:
Use a sortable list instead of a dictionary of values for the return value
## Code After:
import os
import json

from kitchen.settings import KITCHEN_LOCATION

def load_data(data_type):
    retval = []
    nodes_dir = os.path.join(KITCHEN_LOCATION, data_type)
    if not os.path.isdir(nodes_dir):
        raise IOError('Invalid data type or kitchen location. Check your settings.')
    for filename in os.listdir(nodes_dir):
        if filename.endswith('.json'):
            entry = {'name': filename[:-5]}
            f = open(os.path.join(nodes_dir, filename), 'r')
            entry['data'] = json.load(f)
            f.close()
            retval.append(entry)
    return retval

