<commit_before>from __future__ import unicode_literals
import json
import re

from fortuitus.feditor.resolvers import resolve_param


class Params(dict):
    """ Represents query parameters, JSON serializable."""
    def dumps(self):
        """ Serialize parameters in JSON format. """
        return json.dumps(self)

    @staticmethod
    def loads(s):
        """ Load parameters from JSON format. """
        data = json.loads(s)
        params = Params()
        for name, value in data.items():
            params[name] = value
        return params

    def resolve(self, context={}):
        """ Resolves all params values
        """
        result = Params()
        for name, value in self.iteritems():
            result[name] = resolve_param(value, context)
        return result

    def __unicode__(self):
        return self.dumps()<commit_msg>[*] sort params by alphabet<commit_after>from __future__ import unicode_literals
import json
import re

from fortuitus.feditor.resolvers import resolve_param
from django.utils.datastructures import SortedDict


class Params(SortedDict):
    """ Represents query parameters, JSON serializable."""
    def dumps(self):
        """ Serialize parameters in JSON format. """
        return json.dumps(self)

    @staticmethod
    def loads(s):
        """ Load parameters from JSON format. """
        data = json.loads(s)
        params = Params()
        for name in sorted(data):
            params[name] = data[name]
        return params

    def resolve(self, context={}):
        """ Resolves all params values
        """
        result = Params()
        for name, value in self.iteritems():
            result[name] = resolve_param(value, context)
        return result

    def __unicode__(self):
        return self.dumps()
{'fraction_non_alphanumeric': 0.10106085985482971, 'fraction_numerical': 0.0, 'mean_word_length': 2.506849315068493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5689084', 'n_tokens_mistral': 491, 'n_tokens_neox': 477, 'n_words': 150}