<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list_asn(self, auth, asn=None):
 """ List AS numbers matching `spec`. * `auth` [BaseAuth] AAA options. * `spec` [asn_spec] An automous system number specification. If omitted, all ASNs are returned. Returns a list of dicts. This is the documentation of the internal backend function. It's exposed over XML-RPC, please also see the XML-RPC documentation for :py:func:`nipap.xmlrpc.NipapXMLRPC.list_asn` for full understanding. """


        if asn is None:
            asn = {}

        self._logger.debug("list_asn called; asn: %s" % unicode(asn))

        sql = "SELECT * FROM ip_net_asn"
        params = list()

        where, params = self._expand_asn_spec(asn)
        if len(params) > 0:
            sql += " WHERE " + where

        sql += " ORDER BY asn ASC"

        self._execute(sql, params)

        res = list()
        for row in self._curs_pg:
            res.append(dict(row))

        return res