<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _auto(method, fields, count, percent, key_field, ascending):
 """Construct a sampling function according to the provided sampling technique, provided all its needed fields are passed as arguments Args: method: one of the supported sampling methods: {limit,random,hashed,sorted} fields: an optional list of field names to retrieve. count: maximum number of rows to limit the sampled results to. percent: the percentage of the resulting hashes to select if using hashed sampling key_field: the name of the field to sort the rows by or use for hashing ascending: whether to sort in ascending direction or not. Returns: A sampling function using the provided arguments Raises: Exception if an unsupported mathod name is passed """

    if method == 'limit':
      return Sampling.default(fields=fields, count=count)
    elif method == 'random':
      return Sampling.random(fields=fields, percent=percent, count=count)
    elif method == 'hashed':
      return Sampling.hashed(fields=fields, field_name=key_field, percent=percent, count=count)
    elif method == 'sorted':
      return Sampling.sorted(fields=fields, field_name=key_field, ascending=ascending, count=count)
    else:
      raise Exception('Unsupported sampling method: %s' % method)