[Question]
  [
[This challenge](https://codegolf.stackexchange.com/questions/61808/lossy-sorting-implement-dropsort) already describes dropsort. However, I'm kinda lazy and I really only need my array to be a bit more sorted than before, it doesn't need to be sorted *all the way*.
In Drop Sort, we drop every element less than *any* element before it. In Lazy Drop Sort, we drop every element less than the one *strictly preceding* it. 
Here's an example. Consider the following array:
```
8 6 9 9 7 2 3 8 1 3
```
Let's mark every element less than the one before it.
```
8 6 9 9 7 2 3 8 1 3
  ^     ^ ^     ^
```
Notice how neither `3` was marked, nor the last `8`. They are all larger than the single element to the left of them.
Completing the algorithm, removing the marked elements, we get:
```
8 9 9 3 8 3
```
That *basically* looks more sorted. Kinda. I'm lazy.
Your task, as you may have already deduced, is to implement this algorithm.
Input is an array of at least 1 positive integer between 1 and 9, so you can take a string of digits as well.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), fewest bytes wins!
Additional test cases:
```
1
1
1 2 3
1 2 3
5 3 1
5
1 2 3 2 1
1 2 3
1 1 1 9 9 9 1 1 1 9 9 9 1 1 1
1 1 1 9 9 9 1 1 9 9 9 1 1
9 9
9 9
5 2 4 2 3
5 4 3
```
  
[Answer]
# JavaScript (ES6), ~~28~~ 25 bytes
*Saved 3 bytes thanks to @Shaggy*
```
a=>a.filter(n=>~-a<(a=n))
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i5RLy0zpyS1SCPP1q5ON9FGI9E2T1Pzf3J@XnF@TqpeTn66RppGtIWOgpmOgiUYmesoGOkoGOsoAAUNgYxYoHIA "JavaScript (Node.js) – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
```
m←ġ<
```
[Try it online!](https://tio.run/##yygtzv7/P/dR24QjC23@//8fbaFjpmMJhOY6RjrGOhY6hjrGsQA "Husk – Try It Online")
### Explanation
```
m←ġ<
  ġ<    Group the numbers into decreasing sequences
m←      Keep the first element of each sequence
```
[Answer]
# [R](https://www.r-project.org/), 27 bytes
```
(l=scan())[c(T,diff(l)>=0)]
```
[Try it online!](https://tio.run/##K/r/XyPHtjg5MU9DUzM6WSNEJyUzLU0jR9PO1kAz9r@FgpmCJRCaKxgpGCtYKBgqGP8HAA "R – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~9~~ 8 bytes
Saved one byte thanks to Giuseppe.
```
0yd0<h~)
```
[Try it online!](https://tio.run/##y00syfn/36AyxcAmo07z//9oCwUzBUsgNFcwUjBWsFAwVDCOBQA "MATL – Try It Online")
---
**Explanation:**
```
0                 % Push a zero
 y                % Implicitly grab the input and duplicate it.
                  % Stack: [8 6 9 9 7 2 3 8 1 3], 0, [8 6 9 9 7 2 3 8 1 3]
  d               % The difference between each number of the last element:
                  % Stack: [8 6 9 9 7 2 3 8 1 3], 0, [-2, 3, 0, -2, -5, 1, 5, -7, 2]
   0<             % Which are negative?
                  % Stack: [8 6 9 9 7 2 3 8 1 3], 0, [1 0 0 1 1 0 0 1 0]
     h            % Concatenate. Stack: [8 6 9 9 7 2 3 8 1 3], [0 1 0 0 1 1 0 0 1 0] 
      ~           % Negate. Stack: [8 6 9 9 7 2 3 8 1 3], [1 0 1 1 0 0 1 1 0 1]
       )          % Index. Stack: [8 9 9 3 8 3]
```
[Answer]
# [Perl 5](https://www.perl.org/).10.0 + `-nl`, 16 bytes
```
$f>$_||say;$f=$_
```
[Try it online!](https://tio.run/##K0gtyjH9/18lzU4lvqamOLHSWiXNViX@/38LLjMuSyA05zLiMuay4DLkMv6XX1CSmZ9X/F83L@e/rq@pnqGBngEA "Perl 5 – Try It Online")
[Answer]
# Haskell, 29 bytes
```
f s=[b|(a,b)<-zip(0:s)s,a<=b]
```
just a simple list comprehension.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~8~~ 7 bytes
*Saved 1 byte thanks to @Oliver*
```
k@>(U=X
```
[Test it online!](https://ethproductions.github.io/japt/?v=1.4.5&code=a0A+KFU9WA==&input=WzggNiA5IDkgNyAyIDMgOCAxIDNd)
Alternatives:
```
f@T§(T=X
k@ä>0 gY
i0 ò> mÅ c
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 5 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
âÿ╠╦░
```
[Run and debug this online](https://staxlang.xyz/#p=8398cccbb0&i=[8+6+9+9+7+2+3+8+1+3]&a=1)
Unpacking, ungolfing, and commenting the code, we get this.
```
Z   Push a zero under the input
f   Use the rest of the program as a filter on the input.  Output passing elements.
>   Current element is greater than previous?
_~  Push current element to the input stack; when the main stack is empty, pops fall back to this
!   Logical not; applies to the result of the greater-than
```
[Run this one](https://staxlang.xyz/#c=Z%09Push+a+zero+under+the+input%0Af%09Use+the+rest+of+the+program+as+a+filter+on+the+input.++Output+passing+elements.%0A%3E%09Current+element+is+greater+than+previous%3F%0A_%7E%09Push+current+element+to+the+input+stack%3B+when+the+main+stack+is+empty,+pops+fall+back+to+this%0A%21%09Logical+not%3B+applies+to+the+result+of+the+greater-than&i=[8+6+9+9+7+2+3+8+1+3]&a=1)
The ordering of the instructions is awkward but there's a reason for it. Stax source code packing doesn't always yield the same size output for the same size input. Basically, you have a chance to save a byte if the last character of source has a lower character code. Well, `!` has one of the lowest codes you can get for a printable character. (33 specifically) Many 6 byte ASCII stax programs can't pack any smaller. But if they end with a `!`, then they can. So the reason for this particular ordering of instructions is to ensure that the logical not ends up at the end of the program.
[Answer]
# J, 12 Bytes
```
#~1,2&(<:/\)
```
### Explanation:
```
#~1,2&(<:/\)    | Whole function, executed as a hook
       <:/      | Distribute <: (greater or equal) over an array
    2&(   \)    | Apply to each sub array of length 2
  1,            | Append a 1 to the front
#~              | Choose elements from the original array
```
### Examples:
```
    2&(<:/\) 8 6 9 9 7 2 3 8 1 3
0 1 1 0 0 1 1 0 1
    1,2&(<:/\) 8 6 9 9 7 2 3 8 1 3
1 0 1 1 0 0 1 1 0 1
    (1 0 1 1 0 0 1 1 0 1) # 8 6 9 9 7 2 3 8 1 3
8 9 9 3 8 3
    f =: #~1,2&(<:/\)
    f 8 6 9 9 7 2 3 8 1 3
8 9 9 3 8 3
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/lesMdYzUNGys9GM0/2tyKXClJmfkK6QpWCiYKVgCobmCkYIxkGeoYPwfAA "J – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
>Ɲ0;¬×
```
I/O is on strings.
[Try it online!](https://tio.run/##y0rNyan8/9/u2FwD60NrDk////@/uoWZpaW5kbGFobE6AA "Jelly – Try It Online")
[Answer]
# Java 8, ~~66~~ ~~55~~ 48 bytes
```
l->{for(int i=0;;)if(i>(i=l.next()))l.remove();}
```
-11 bytes after a tip from *@OlivierGrégoire*.  
-7 more bytes thanks to *@OlivierGrégoire*.
**Explanation:**
[Try it online.](https://tio.run/##fZBBa8IwFIDv/op3TCCGbcLm6Crs4EHYvHgcO2TxqenSRJLXriL97V1aJ4qHEQiEfHz5XgpVq3Gx/u60VTHCuzLuOAIwjjBslEZY9keA2ps1aFYkXFZkrHwzkRYJUuTDyyLhWwwzsDxLeDtKWyRFRsMSHOTQ2fHsuPGBJTGY/C7LuNkwM2Mmt9JhQ4xzbmXA0tfIeNZ2We/YV182Of5UQ0OZCtmKgnHbj0/FT3WXrNcQ1KFvuzQRRkoJDn/@5djNZZQq9gCbikfxnNaTeBATMRX3YsKHMQEoHE4BAE5q1r8k7dXHsDPYakV6d/XE0q8qvZtbLNHRvNG4J@MdYMPPwtUhEpbSVyT3aVqybvCfhcM3t90v)
```
l->{                     // Method with Integer-ListIterator parameter and no return-type
  for(int i=0;;)         //  Loop over all items
    if(i>(i=l.next()))   //   If the current item is larger than the next
      l.remove();}       //    Remove this next item
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 21 bytes
```
@(x)x(~[0,diff(x)<0])
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0KzQqMu2kAnJTMtDcixMYjV/J@mEW2hYKZgCYTmCkYKxgoWCoYKxkAJAA "Octave – Try It Online")
**Explanation:**
Take a vector `x` as input, and create a vector `[0, diff(x)<0]`, where `diff(x)` is a vector with the difference between all adjacent elements. Keep only those that are negative by comparing it to zero, giving us a list of all the elements we want to drop.
We then select the elements from the input vector that we want to keep.
[Answer]
# [V](https://github.com/DJMcMayhem/V), 25 bytes
```
òjälá k$yl+@"òç-/d
ç /dw
```
[Try it online!](https://tio.run/##K/v///CmrMNLcg4vVMhWqczRdlCSOLzp8HJd/RSuw8sV9FPK//@34DLjsgRCcy4jLmMuCy5DLmMA "V – Try It Online")
Hexdump:
```
00000000: f26a e46c e120 6b24 796c 2b40 2218 f2e7  .j.l. k$yl+@"...
00000010: 2d2f 640a e720 2f64 77                   -/d.. /dw
```
Worst language for the job. But I did it [for a dare](https://chat.stackexchange.com/transcript/message/43567339#43567339).
[Answer]
# SWI-Prolog, 44 bytes
```
[A,B|C]-[A|E]:-B<A,[B|C]-[B|E];[B|C]-E. L-L.
```
Usage: Call "*List*-X" where *List* is a bracket-enclosed, comma-separated list e.g. [1,4,5,1,11,6,7].
[Answer]
# [Triangularity](https://github.com/Mr-Xcoder/Triangularity), 71 bytes
```
.....).....
....IEL....
...)rFD)...
..2+)IE)w..
.+h)2_stDO.
={M)IEm}...
```
[Try it online!](https://tio.run/##KynKTMxLL81JLMosqfz/Xw8ENMEkF4jwdPWBsTWL3Fw0IWwjbU1PV81yEFs7Q9MovrjExV@Py7baFyicWwtU8/9/tIWOmY4lEJrrGOkY61joGOoYxwIA "Triangularity – Try It Online")
## How it works?
```
)IEL)rFD)2+)IE)w+h)2_stDO={M)IEm} – Full program.
)IE                               – Get the 0th input I and evaluate it.
   L)r                            – And push the range [0 ... length of I).
      F                   {       – Filter the integers in this range which satisfy:
       D)2+)IE)w+h)2_stDO=        – This condition. Runs each element E on a separate
                                    stack and discard those that don't meet the criteria.
       D)2+                       – Duplicate and add 2 to the second copy.
           )IE                    – Retrieve I again.
              )                   – Push a 0 onto the stack.
               w                  – Wrap the 0 in a list. [0]
                +                 – Prepend it to I.
                 h                – Head. Trim the elements after index E+2.
                  )2_             – Literal -2.
                     st           – Tail.
                       DO=        – Check whether the result is invariant over sorting.
                           M)IEm} – Last part: indexing into the input.
                           M    } – For each index that satisfies the conditions:
                            )IEm  – Retrieve the element of I at that position.
```
[Answer]
# [Python](https://docs.python.org/2/), 40 bytes
```
f=lambda h,*t:t and h+f(*t)[h>t[0]:]or h
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P802JzE3KSVRIUNHq8SqRCExL0UhQztNQ6tEMzrDriTaINYqNr9IIeN/QVFmXokCUCIzr6C0RENT87@6hZmlpbmRsYWhsToA "Python 2 – Try It Online")
Input as tuple of characters.
---
# [Python 3](https://docs.python.org/3/), 41 bytes
```
p=''
for x in input():x<p or print(x);p=x
```
[Try it online!](https://tio.run/##K6gsycjPM/7/v8BWXZ0rLb9IoUIhMw@ICkpLNDStKmwKFIBiBUWZeSUaFZrWBbYV//9bmFlamhsZWxgaAwA "Python 3 – Try It Online")
String input.
---
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 33 bytes
```
Pick[#,Arg[#-{0}~Join~Most@#],0]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78H1CUmVcS/T8gMzk7WlnHsSg9Wlm32qC2zis/M6/ON7@4xEE5VscgVu2/goNCtYWOmY4lEJrrGOkY61joGOoY1yrE/gcA "Wolfram Language (Mathematica) – Try It Online")
## How it works
The code `# - {0}~Join~Most@#` turns an array `{a,b,c,d,e,f}` into `{a,b-a,c-b,d-c,e-d,f-e}`. Applying `Arg` to this sets negative numbers to `Pi` and nonnegative numbers to `0`. 
`Pick[#, ..., 0]&` picks out the entries of `#` where `...` has a `0`: in our case, exactly the elements that yield a nonnegative number when you subtract the previous element. In other words, these are exactly the entries we want to keep when lazydropsorting.
[Answer]
# [Wonder](https://github.com/wonderlang/wonder), 27 bytes
```
-> ':1.!> 'sS#<=.cns2.++[0]
```
Usage example:
```
(-> ':1.!> 'sS#<=.cns2.++[0])[8 6 9 9 7 2 3 8 1 3]
```
# Explanation
Ungolfed version:
```
(map get 1).(fltr sS <=).(cns 2).(++ [0])
```
Prepend `0`, get list of consecutive pairs, keep list items where first number <= second number, get second number of each pair.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 20 bytes
```
#&@@@Split[#,##>0&]&
(* or *)
Max/@Split[#,##>0&]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2ar8V9ZzcHBIbggJ7MkWllHWdnOQC1W7b@mNVdAUWZeiYNWmr5DNRdXtWGtDpDQUTDSUTAGMU2BtI4CsiiYhAlAkCUM4RQBKQcJQI0EmmACtYOLq/Y/AA "Wolfram Language (Mathematica) – Try It Online")
### Explanation
`Input = {8, 6, 9, 9, 7, 2, 3, 8, 1, 3}`
```
Split[#,##>0&]
```
Group consecutive elements that are strictly decresasing: `{{8, 6}, {9}, {9, 7, 2}, {3}, {8, 1}, {3}}`
```
#&@@@
```
Take the first element of each: `{8, 9, 9, 3, 8, 3}`
[Answer]
# [Python 2](https://docs.python.org/2/), ~~52~~ ~~46~~ ~~45~~ 42 bytes
```
lambda a:[v for v,w in zip(a,[1]+a)if v/w]
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHRKrpMIS2/SKFMp1whM0@hKrNAI1En2jBWO1EzM02hTL889n9BUWZeiUKaRrSFjpmOJRCa6xjpGOtY6BjqGMdqcsGlDcHCJjqmQGXmQGnLWM3/AA "Python 2 – Try It Online")
---
Saved:
* -3 bytes, thanks to Rod
[Answer]
# APL+WIN, 14 bytes
Prompts for screen input of a vector of integers.
```
(1,1>2-/v)/v←⎕
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes
```
ĆÁü›_Ï
```
[Try it online!](https://tio.run/##MzBNTDJM/f//SNvhxsN7HjXsij/c//9/tIWOgpmOgiUYmesoGOkoGOsoAAUNgYxYAA "05AB1E – Try It Online")
**Explanation**
```
Ć        # append the head of the list
 Á       # rotate right
  ü›     # apply pair-wise greater-than
    _    # logical negate each
     Ï   # keep elements of input that are true in this list
```
[Answer]
# [Kotlin](https://kotlinlang.org), 39 bytes
```
a->a.filterIndexed{i,v->i<1||v>=a[i-1]}
```
[Try it online!](https://tio.run/##PYzLCsIwEEX3@YpZJpAIVfBFm31BcOFSXESalME0SpoGoe23x1jEYQbuHTjn8QwWXTKDg06ho1F55VvI1x/hEjy6lsFIIE9UFtzQ3bXvoQKLfTgbuuew5XBYdsdhzWHDIT@LHNiCvbIjUEN/KGNkJuTrMkegp2wpaxckAyHh37J/TEpItTJog/a1a/RbNyPyKCSWxTRFWakriuI2pzl9AA "Kotlin – Try It Online")
Filter items that are either the first item (index==0, or even shorter index<1) OR the current Value is greater than or equal to the previous item (a[i-1]).
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 11 [bytes](https://github.com/abrudz/SBCS)
```
{⍵⌿⍨1⍪2≤⌿⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v/pR79ZHPfsf9a4wfNS7yuhR5xIwb2vt//9pCo/aJijgVMCVpmChYKZgCYTmCkYKxkCeoYIxAA "APL (Dyalog Unicode) – Try It Online")
This is actually pretty similar to Graham's answer, but in Dyalog, and independently developed. Also, more symmetric.
[Answer]
# [K4](http://kx.com/download/), 10 bytes
**Solution:**
```
x_/|&<':x:
```
**Example:**
```
q)k)x_/|&<':x:8 6 9 9 7 2 3 8 1 3
8 9 9 3 8 3
```
**Explanation:**
Find indices where element is less than preceding, remove these indices from the input
```
x_/|&<':x: / the solution
        x: / store input as x
     <':   / less-than each-previous
    &      / indices where true
   |       / reverse
 _/        / drop-over
x          / the input
```
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/attache), 24 bytes
```
{Mask[1'(Delta!_>=0),_]}
```
[Try it online!](https://tio.run/##SywpSUzOSP2fpmBlq/C/2jexODvaUF3DJTWnJFEx3s7WQFMnPrb2f15@UW5iTmZVKkiZa1lijq1dcEFOZgkXl19qakpxtEpBQXJ6LBcXV0BRZl5JSGpxiXNicWpxdJoDXKeOQjSXkoWCmYIlEJorGCkYK1goGCoYK@lwKRmCCZAYiGEKlEKIADGUA4KWYIjBBikAciC6jRRMwEZxxcb@BwA "Attache – Try It Online")
## Explanation
`Mask` selects all elements from its second argument which correspond to truthy elements in its first argument. `1'(Delta!_>=0)` calculates the indices which correspond to elements that are supposed to be in the final array.
## Other attempts
28 bytes (pointfree): `~Mask#(1&`'##Delta#`>=#C[0])`
32 bytes: `{Mask[1'(&`<= =>Slices[_,2]),_]}`
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 33 + 18 = 51bytes
```
x=>x.Where((a,n)=>n<1||x[n-1]<=a)
```
[Try it online!](https://tio.run/##XVDBasJAFDxnv@LhKcE1kAqtJSYXsVBoTz14EJHX7VMXkpd032oV9dvTTe2hlLnMmwfDzBgZmcZRtxfLW3g7iac6V3@v9MXy5z9p1lQVGW8bllwx1iQtGoL2rEyFIj1pnT2gJxCP3hp42rOZWvbLlYbnOe9rcvheUbkpumNRHtPFjhzFMWpOipKn2eVyXPIoW00LTLpc/bocGvsBr2g5Fu9CnuUK0G0lOavoJsBaoIAbT@d160@5ijahIJpdfEAHCJZhEzN9wU@a80Tf68eAB32nx3qiMz2@Jr1htJYi2A1xONCDXF1VNAt1m4rShbOewioUryXpPwHdNw "C# (.NET Core) – Try It Online")
basically the statement is where x is the first int in the array, or is greater than or equal to the previous number, keep it. Else drop it.
[Answer]
# [Swift 4](https://developer.apple.com/swift/), ~~56~~ 55 bytes
```
{var l=0;print($0.filter{($0>=l,l=$0).0})}as([Int])->()
```
[Try it online!](https://tio.run/##Ky7PTCsx@Z@TWqKQpmD7v7ossUghx9bAuqAoM69EQ8VALy0zpyS1qBrItLPN0cmxVTHQ1DOo1axNLNaI9swridXUtdPQ/J@mEW2ho2Cmo2AJRuY6CkY6CsY6CkBBQyAjVvM/AA)
## Explanation
```
{var l=0;           // Declare variable l
print($0.filter{(   // Print every element e in the input
  $0>=l,            //   where e >= l
  l=$0).0})         //   And set l to e
}as([Int])->()      // Set the input type to integer array
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
0;>ƝżµḢÐṂ
```
[Try it online!](https://tio.run/##y0rNyan8/9/A2u7Y3KN7Dm19uGPR4QkPdzb9//8/2kLHTMcSCM11jHSMdSx0DHWMYwE "Jelly – Try It Online")
This feels pretty bulky, wouldn't be that surprised if there is a better way.
```
0;>ƝżµḢÐṂ
   Ɲ       For each adjacent pair in the input...
  >        ...is the first element greater than the second? (yields a list of 0/1)
0;         prepend a zero to this list (always keep the first element)
    ż      zip with the input
     µ     new monadic link
       ÐṂ  keep elements of the list with minimal value of... (Ðḟ would have worked here and been slightly more clear but I'll leave it as it is)
      Ḣ    ...their first element
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~136~~, 120 bytes
```
((())){{}([{}]({}))([({}<(())>)](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}{{}(({})<>)(())(<>)}{}([][()])}{}{}<>{{}({}<>)<>}<>
```
Here it is formatted and *"readable"*.
```
((()))
{
    {}
    ([{}]({}))
    ([({}<(())>)](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}
    {
        {}(({})<>)(())(<>)
    }
    {}
    ([][()])
}{}{}<>
{
    {}
    ({}<>)<>
}<>
```
[Try it online!](https://tio.run/##HYwxCsNQDEOv4lEeOqSBpgHji3z@kAyF0JIhq/HZf6ziQX6ypf3ajvPx@W3fMQCoakSiRXZEqqKVGH3XDvM6l1FonpEBWKSTIospjDNav4wxk2zsDdq5/t/KobLGfIxJ3vKStWaRp8xFk8w3 "Brain-Flak – Try It Online")
]