<commit_before>package bsw

type Result struct {
	Source   string `json:"src"`
	IP       string `json:"ip"`
	Hostname string `json:"hostname"`
}<commit_msg>Implements sorting<commit_after>package bsw

import (
	"net"
	"encoding/binary"
)

type Result struct {
	Source   string `json:"src"`
	IP       string `json:"ip"`
	Hostname string `json:"hostname"`
}

type Results []Result

func (r Results) Len() int { return len(r) }
func (r Results) Swap(i, j int) { r[i], r[j] = r[j], r[i] }

// Sorts by IPv4 address, IPv6 addresses will be show first and will be unsorted.
func (r Results) Less(i, j int) bool {
	first := net.ParseIP(r[i].IP).To4()
	second := net.ParseIP(r[j].IP).To4()
	if first == nil {
		return true
	}
	if second == nil {
		return false
	}
	return binary.BigEndian.Uint32(first) < binary.BigEndian.Uint32(second)
}
{'fraction_non_alphanumeric': 0.15060240963855423, 'fraction_numerical': 0.00963855421686747, 'mean_word_length': 3.9760479041916166, 'pattern_counts': {'":': 0, '<': 4, '<?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': '3893871', 'n_tokens_mistral': 313, 'n_tokens_neox': 305, 'n_words': 90}