<commit_before>from operator import attrgetter

from bin import Bin

class Packer(object):
    def __init__(self, bin_count, bin_size):
        self._bin_count = bin_count
        self._bin_size = bin_size

    def pack(self, items, fill_limit):
        bins = []
        other = Bin(-1)

        for x in range(0, self._bin_count):
            bins.append(Bin(x))

        items = sorted(items, key=attrgetter('weight'), reverse=True)
        
        for item in items:
            stored = False

            bins = sorted(bins, key=attrgetter('weight'))

            for idx, location in enumerate(bins):
                if location.weight < fill_limit and item.weight <= (fill_limit - location.weight):
                    location.add_item(item)
                    stored = True
<commit_msg>Added priority to the packer<commit_after>from operator import attrgetter

from bin import Bin

class Packer(object):
    def __init__(self, bin_count, bin_size):
        self._bin_count = bin_count
        self._bin_size = bin_size

    def pack(self, items, fill_limit):
        bins = []
        other = Bin(-1)

        for x in range(0, self._bin_count):
            bins.append(Bin(x))

        items = sorted(items, key=attrgetter('weight'), reverse=True)
        items = sorted(items, key=attrgetter('value'), reverse=True)
        
        for item in items:
            stored = False

            bins = sorted(bins, key=attrgetter('weight'))

            for idx, location in enumerate(bins):
                if location.weight < fill_limit and item.weight <= (fill_limit - location.weight):
                    location.add_item(item)
                    stored = True

{'fraction_non_alphanumeric': 0.09821428571428571, 'fraction_numerical': 0.002380952380952381, 'mean_word_length': 2.0675182481751824, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5170835', 'n_tokens_mistral': 490, 'n_tokens_neox': 465, 'n_words': 126}