2 added 104 characters in body

# Factor Sort

This challenge involves sorting positive integers based on a lexicographical ordering of their prime factorizations.

## Overview

lexicographical sorting, used in dictionaries, applies lexicographical order which extends alphabetical order to words:

a
aa
aaa
aaron
ab
abandoned
abc
aberdeen


When programming this sort, however, we typically don't extend alphabetical ordering per se, but rather we extend the order of integers used for an encoding. For example, the same sorting above through ASCII encoding is really:

97
97 97
97 97 97
97 97 114 111 110
97 98
97 98 97 119 100 111 110 101 100
97 98 99
97 98 101 114 100 101 101 110


It is this type of ordering that we're after here... lexicographical ordering by extension of numeric comparison as opposed to alphabetical order.

## The Challenge

In this challenge, you will be sorting positive integers by their ordered prime factorizations (ordered in the sense that the primes are listed smallest to largest). To handle the special case number 1, we can simply say its prime factorization is an empty list, which lexicographically sorts prior to any other number's prime factorization. We'll call this type of sorting factor sorting.

For example, the numbers from 1 to 10, factor sorted, are: 1 2 4 8 6 10 3 9 5 7. To see why, here they are again with the ordered prime factorizations:

 1 []
2 [2]
4 [2 2]
8 [2 2 2]
6 [2 3]
10 [2 5]
3 [3]
9 [3 3]
5 [5]
7 [7]


## Rules

Write a function or program that factor sorts a list of positive integers. Input and output can be anything reasonable, so long as the input is in the specified arbitrary order and the correct output order is apparent from the output.

Keep in mind that the output should be factor sorted numbers, not their prime factorization.

If it matters, numbers in the input will always be ≤ 7928, so:

• The only primes in the prime factorization list are the first 1000 primes
• Composites have factors no larger than 89 inclusive

This is code golf; shortest code in bytes wins.

## Test cases

1 2 3 4 5 6 7 8 9 10
->
1 2 4 8 6 10 3 9 5 7

100 200 300 400 500 600 700 800 900
->
800 400 600 200 900 300 100 500 700

1472 4417 1425 1452 4480 200 339 2868 3835 4760
->
4480 1472 200 4760 1452 2868 1425 339 3835 4417

2 4 6 46 62 466 622 4666 6238
->
2 4 6 46 62 466 622 4666 6238


# Factor Sort

This challenge involves sorting positive integers based on a lexicographical ordering of their prime factorizations.

## Overview

lexicographical sorting, used in dictionaries, applies lexicographical order which extends alphabetical order to words:

a
aa
aaa
aaron
ab
abandoned
abc
aberdeen


When programming this sort, however, we typically don't extend alphabetical ordering per se, but rather we extend the order of integers used for an encoding. For example, the same sorting above through ASCII encoding is really:

97
97 97
97 97 97
97 97 114 111 110
97 98
97 98 97 119 100 111 110 101 100
97 98 99
97 98 101 114 100 101 101 110


It is this type of ordering that we're after here... lexicographical ordering by extension of numeric comparison as opposed to alphabetical order.

## The Challenge

In this challenge, you will be sorting positive integers by their ordered prime factorizations (ordered in the sense that the primes are listed smallest to largest). To handle the special case number 1, we can simply say its prime factorization is an empty list, which lexicographically sorts prior to any other number's prime factorization. We'll call this type of sorting factor sorting.

For example, the numbers from 1 to 10, factor sorted, are: 1 2 4 8 6 10 3 9 5 7. To see why, here they are again with the ordered prime factorizations:

 1 []
2 [2]
4 [2 2]
8 [2 2 2]
6 [2 3]
10 [2 5]
3 [3]
9 [3 3]
5 [5]
7 [7]


## Rules

Write a function or program that factor sorts a list of positive integers. Input and output can be anything reasonable, so long as the input is in the specified arbitrary order and the correct output order is apparent from the output.

Keep in mind that the output should be factor sorted numbers, not their prime factorization.

If it matters, numbers in the input will always be ≤ 7928, so:

• The only primes in the prime factorization list are the first 1000 primes
• Composites have factors no larger than 89 inclusive

## Test cases

1 2 3 4 5 6 7 8 9 10
->
1 2 4 8 6 10 3 9 5 7

100 200 300 400 500 600 700 800 900
->
800 400 600 200 900 300 100 500 700

1472 4417 1425 1452 4480 200 339 2868 3835 4760
->
4480 1472 200 4760 1452 2868 1425 339 3835 4417

2 4 6 46 62 466 622 4666 6238
->
2 4 6 46 62 466 622 4666 6238


# Factor Sort

This challenge involves sorting positive integers based on a lexicographical ordering of their prime factorizations.

## Overview

lexicographical sorting, used in dictionaries, applies lexicographical order which extends alphabetical order to words:

a
aa
aaa
aaron
ab
abandoned
abc
aberdeen


When programming this sort, however, we typically don't extend alphabetical ordering per se, but rather we extend the order of integers used for an encoding. For example, the same sorting above through ASCII encoding is really:

97
97 97
97 97 97
97 97 114 111 110
97 98
97 98 97 119 100 111 110 101 100
97 98 99
97 98 101 114 100 101 101 110


It is this type of ordering that we're after here... lexicographical ordering by extension of numeric comparison as opposed to alphabetical order.

## The Challenge

In this challenge, you will be sorting positive integers by their ordered prime factorizations (ordered in the sense that the primes are listed smallest to largest). To handle the special case number 1, we can simply say its prime factorization is an empty list, which lexicographically sorts prior to any other number's prime factorization. We'll call this type of sorting factor sorting.

For example, the numbers from 1 to 10, factor sorted, are: 1 2 4 8 6 10 3 9 5 7. To see why, here they are again with the ordered prime factorizations:

 1 []
2 [2]
4 [2 2]
8 [2 2 2]
6 [2 3]
10 [2 5]
3 [3]
9 [3 3]
5 [5]
7 [7]


## Rules

Write a function or program that factor sorts a list of positive integers. Input and output can be anything reasonable, so long as the input is in the specified arbitrary order and the correct output order is apparent from the output.

Keep in mind that the output should be factor sorted numbers, not their prime factorization.

If it matters, numbers in the input will always be ≤ 7928, so:

• The only primes in the prime factorization list are the first 1000 primes
• Composites have factors no larger than 89 inclusive

This is code golf; shortest code in bytes wins.

## Test cases

1 2 3 4 5 6 7 8 9 10
->
1 2 4 8 6 10 3 9 5 7

100 200 300 400 500 600 700 800 900
->
800 400 600 200 900 300 100 500 700

1472 4417 1425 1452 4480 200 339 2868 3835 4760
->
4480 1472 200 4760 1452 2868 1425 339 3835 4417

2 4 6 46 62 466 622 4666 6238
->
2 4 6 46 62 466 622 4666 6238

1

# Factor Sort

This challenge involves sorting positive integers based on a lexicographical ordering of their prime factorizations.

## Overview

lexicographical sorting, used in dictionaries, applies lexicographical order which extends alphabetical order to words:

a
aa
aaa
aaron
ab
abandoned
abc
aberdeen


When programming this sort, however, we typically don't extend alphabetical ordering per se, but rather we extend the order of integers used for an encoding. For example, the same sorting above through ASCII encoding is really:

97
97 97
97 97 97
97 97 114 111 110
97 98
97 98 97 119 100 111 110 101 100
97 98 99
97 98 101 114 100 101 101 110


It is this type of ordering that we're after here... lexicographical ordering by extension of numeric comparison as opposed to alphabetical order.

## The Challenge

In this challenge, you will be sorting positive integers by their ordered prime factorizations (ordered in the sense that the primes are listed smallest to largest). To handle the special case number 1, we can simply say its prime factorization is an empty list, which lexicographically sorts prior to any other number's prime factorization. We'll call this type of sorting factor sorting.

For example, the numbers from 1 to 10, factor sorted, are: 1 2 4 8 6 10 3 9 5 7. To see why, here they are again with the ordered prime factorizations:

 1 []
2 [2]
4 [2 2]
8 [2 2 2]
6 [2 3]
10 [2 5]
3 [3]
9 [3 3]
5 [5]
7 [7]


## Rules

Write a function or program that factor sorts a list of positive integers. Input and output can be anything reasonable, so long as the input is in the specified arbitrary order and the correct output order is apparent from the output.

Keep in mind that the output should be factor sorted numbers, not their prime factorization.

If it matters, numbers in the input will always be ≤ 7928, so:

• The only primes in the prime factorization list are the first 1000 primes
• Composites have factors no larger than 89 inclusive

## Test cases

1 2 3 4 5 6 7 8 9 10
->
1 2 4 8 6 10 3 9 5 7

100 200 300 400 500 600 700 800 900
->
800 400 600 200 900 300 100 500 700

1472 4417 1425 1452 4480 200 339 2868 3835 4760
->
4480 1472 200 4760 1452 2868 1425 339 3835 4417

2 4 6 46 62 466 622 4666 6238
->
2 4 6 46 62 466 622 4666 6238