<commit_before>/*
 ----- BEGIN LICENSE BLOCK -----
 This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0.
 If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 ----- END LICENSE BLOCK -----
 */
package org.pharmgkb.common.comparator;

import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;


/**
 * Comparator for haplotype names.  This takes common allele nomenclature into account (i.e. treat numbers as numbers,
 * not strings).
 *
 * @author <NAME>
 */
public class HaplotypeNameComparator implements Comparator<String> {<commit_msg>Add javadoc.<commit_after>/*
 ----- BEGIN LICENSE BLOCK -----
 This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0.
 If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 ----- END LICENSE BLOCK -----
 */
package org.pharmgkb.common.comparator;

import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;


/**
 * Comparator for haplotype names.  This takes common allele nomenclature into account (i.e. treat numbers as numbers,
 * not strings).
 * 
 * The rules for how this sorts:
 * <ol>
 *   <li>The terms <code>Any</code> and <code>All</code> always get sorted to the beginning</li>
 *   <li>The terms <code>Unknown</code> and <code>Other</code> always get sorted to the end</li>
 *   <li>if the term contains numbers (e.g. *2, H3, *3B) the terms will be String sorted by the initial character(s), 
 *   Integer sorted by the following numbers, then String sorted by any following characters</li>
 *   <li>Otherwise just do regular String sorting</li>
 * </ol>
 *
 * @author <NAME>
 */
public class HaplotypeNameComparator implements Comparator<String> {
{'fraction_non_alphanumeric': 0.12020342117429496, 'fraction_numerical': 0.006934812760055479, 'mean_word_length': 3.7876106194690267, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '5541681', 'n_tokens_mistral': 658, 'n_tokens_neox': 629, 'n_words': 231}