# Is this a half-sort?

## J, ^{20 18 15} 14 bytes

*-1 thanks to Jonah.*

Goes the other way around: sorts the string ('node' -> 'deno'), rotates it back ('deno' -> 'node') and checks if this equals the input. Fits better J trains.

```
-:<.@-:@#|./:~
```

Try it online!

### How it works

```
-:<.@-:@#|./:~
/:~ sort input
<.@-:@# length of input, halved and floored
|. rotate sorted input by that amount
-: input equal to that?
```

## Python 3, ~~45~~ 42 bytes

*-3 bytes thanks to @dingledooper*

```
lambda s:sorted(s)==s+[s.pop(0)for c in s]
```

Try it online!

Takes input as a list of characters. Returns `True`

if the list is half-sorted, `False`

otherwise.

**How**

`[s.pop(0)for c in s]`

gets the first half of the list. After this is evaluated, `s`

only has the later half left.

Thus `s+[s.pop(0)for c in s]`

is the list with the 2 halves swapped. Note that this works because Python evaluates anything inside square brackets first.

I then check if the swapped list is sorted, aka compare it with `sorted(s)`

.

## Pyth, 8 bytes

```
qSzs_c2z
```

Try it online!

Luckily, Pyth offers most of what we need out of the box, so we just need to call the operations necessary.

```
Sz # Sort the input
c2z # Chop the input into two equal pieces (first longer if needed)
_ # Reverse the chopped elements
s # Join them back together
q # Check for equality
```