nodes: 0, module; 1, function_definition; 2, function_name:sort_csv; 3, parameters; 4, block; 5, identifier:in_file; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:"""Sort a CSV file by read name, allowing direct comparison.
      """; 11, assignment; 12, not_operator; 13, block; 14, identifier:out_file; 15, identifier:out_file; 16, binary_operator:"%s.sort" % in_file; 17, parenthesized_expression; 18, expression_statement; 19, with_statement; 20, string:"%s.sort"; 21, identifier:in_file; 22, boolean_operator; 23, assignment; 24, with_clause; 25, block; 26, call; 27, comparison_operator:os.path.getsize(out_file) > 0; 28, identifier:cl; 29, list; 30, with_item; 31, expression_statement; 32, expression_statement; 33, attribute; 34, argument_list; 35, call; 36, integer:0; 37, string:"sort"; 38, string:"-k"; 39, string:"1,1"; 40, identifier:in_file; 41, as_pattern; 42, assignment; 43, call; 44, attribute; 45, identifier:exists; 46, identifier:out_file; 47, attribute; 48, argument_list; 49, call; 50, as_pattern_target; 51, identifier:child; 52, call; 53, attribute; 54, argument_list; 55, identifier:os; 56, identifier:path; 57, attribute; 58, identifier:getsize; 59, identifier:out_file; 60, identifier:open; 61, argument_list; 62, identifier:out_handle; 63, attribute; 64, argument_list; 65, identifier:child; 66, identifier:wait; 67, identifier:os; 68, identifier:path; 69, identifier:out_file; 70, string:"w"; 71, identifier:subprocess; 72, identifier:Popen; 73, identifier:cl; 74, keyword_argument; 75, identifier:stdout; 76, identifier:out_handle
code: def sort_csv(in_file):
      """Sort a CSV file by read name, allowing direct comparison.
      """
      out_file = "%s.sort" % in_file
      if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
          cl = ["sort", "-k", "1,1", in_file]
          with open(out_file, "w") as out_handle:
              child = subprocess.Popen(cl, stdout=out_handle)
              child.wait()
      return out_file