def sort_by_pval(lines, ind):
 def _nan_safe_sort(line):
  'Sort lines based on pvals and force nans to have inf pval.'
  val = float(line.split(' DCTB ')[ind])
  if (not isnan(val)):
   return val
  else:
   return inf
 return ([lines[0]] + sorted(lines[1:], key=_nan_safe_sort))

def sort_by_pval ( lines , ind ) : def _nan_safe_sort ( line ) : val = float ( line . split ( ' DCTB ' ) [ ind ] ) if ( not isnan ( val ) ) : return val else : return inf return ( [ lines [ 0 ] ] + sorted ( lines [ 1 : ] , key = _nan_safe_sort ) )
sort lines with pvals in descending order .