class_docstr: List derivative with a special access attributes.
  
  These are normal lists, but with the special attributes:
  
  * .l (or .list) : value as list (the list itself).
  * .n (or .nlstr): value as a string, joined on newlines.
  * .s (or .spstr): value as a string, joined on spaces.
  * .p (or .paths): list of path objects (requires path.py package)
  
  Any values which require transformations are computed only once and
  cached.
class_docstr_tok: ["List","derivative","with","a","special","access","attributes",".","These","are","normal","lists",",","but","with","the","special","attributes",":","*",".l","(","or",".list",")",":","value","as","list","(","the","list","itself",")",".","*",".n","(","or",".nlstr",")",":","value","as","a","string",",","joined","on","newlines",".","*",".s","(","or",".spstr",")",":","value","as","a","string",",","joined","on","spaces",".","*",".p","(","or",".paths",")",":","list","of","path","objects","(","requires","path.py","package",")","Any","values","which","require","transformations","are","computed","only","once","and","cached","."]
docstr: sort by specified fields (see fields())
  
  Example::
  
      a.sort(1, nums = True)
  
  Sorts a by second field, in numerical order (so that 21 > 3)
docstr_tok: ["sort","by","specified","fields","(","see","fields","(",")",")","Example",":",":","a.sort","(","1",",","nums","=","True",")","Sorts","a","by","second","field",",","in","numerical","order","(","so","that","21",">","3",")"]
code: def sort(self, field=None, nums=False):
      """sort by specified fields (see fields())
  
      Example::
  
          a.sort(1, nums = True)
  
      Sorts a by second field, in numerical order (so that 21 > 3)
  
      """
  
      # decorate, sort, undecorate
      if field is not None:
          dsu = [[SList([line]).fields(field), line] for line in self]
      else:
          dsu = [[line, line] for line in self]
      if nums:
          for i in range(len(dsu)):
              numstr = "".join([ch for ch in dsu[i][0] if ch.isdigit()])
              try:
                  n = int(numstr)
              except ValueError:
                  n = 0
              dsu[i][0] = n
  
      dsu.sort()
      return SList([t[1] for t in dsu])
  
imports: from __future__ import absolute_import
  import os
  import re
  import sys
  import textwrap
  from string import Formatter
  from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest
  from IPython.utils import py3compat
label_desc: Use image node_id 7 for calling the SList obj's underlying member method code with example usage: obj.sort(field, nums) and returns: SList