[Question]
  [
Most everyone here is familiar with Pascal's Triangle. It's formed by successive rows, where each element is the sum of its two upper-left and upper-right neighbors. Here are the first `5` rows (borrowed from [Generate Pascal's triangle](https://codegolf.stackexchange.com/q/3815/42963)):
```
    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1
  . . .
```
Collapse these rows to the left
```
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
. . .
```
Sort them in ascending order
```
1
1 1
1 1 2
1 1 3 3
1 1 4 4 6
. . .
```
Read this triangle by rows
```
[1, 1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 1, 4, 4, 6 ...]
```
Given an input `n`, output the `n`th number in this series. This is [OEIS 107430](http://oeis.org/A107430).
### Rules
* You can choose either 0- or 1-based indexing. Please state which in your submission.
* The input and output can be assumed to fit in your language's native integer type.
* The input and output can be given by [any convenient method](http://meta.codegolf.stackexchange.com/q/2447/42963).
* Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/q/1061/42963) are forbidden.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so all usual golfing rules apply, and the shortest code (in bytes) wins.
  
[Answer]
# JavaScript (ES6), 79 bytes
0-indexed.
```
f=(n,a=[L=1])=>a[n]||f(n-L,[...a.map((v,i)=>k=(x=v)+~~a[i-1-i%2]),L++&1?k:2*x])
```
### Demo
```
f=(n,a=[L=1])=>a[n]||f(n-L,[...a.map((v,i)=>k=(x=v)+~~a[i-1-i%2]),L++&1?k:2*x])
console.log([...Array(79).keys()].map(n => f(n)).join(', '))
```
### How?
```
f = (                       // f = recursive function taking:
  n,                        //   n = target index
  a = [L = 1]               //   a[] = current row, L = length of current row
) =>                        //
  a[n] ||                   // if a[n] exists, stop recursion and return it
  f(                        // otherwise, do a recursive call to f() with:
    n - L,                  //   n minus the length of the current row
    [                       //   an array consisting of:
      ...a.map((v, i) =>    //     replace each entry v at position i in a[] with:
        k =                 //       a new entry k defined as:
        (x = v) +           //       v +
        ~~a[i - 1 - i % 2]  //       either the last or penultimate entry
      ),                    //     end of map()
      L++ & 1 ?             //     increment L; if L was odd:
        k                   //       append the last updated entry
      :                     //     else:
        2 * x               //       append twice the last original entry
    ]                       //   end of array update
  )                         // end of recursive call
```
This algorithm directly generates the sorted rows of Pascal's Triangle. It updates **n** according to the length of the previous row until **a[n]** exists. For instance, 6 iterations are required for **n = 19**:
```
 L | n  | a[]
---+----+------------------------
 1 | 19 | [ 1 ]
 2 | 18 | [ 1, 1 ]
 3 | 16 | [ 1, 1, 2 ]
 4 | 13 | [ 1, 1, 3, 3 ]
 5 |  9 | [ 1, 1, 4, 4, 6 ]
 6 |  4 | [ 1, 1, 5, 5, 10, 10 ]
                        ^^
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 46 bytes
```
@(n)(M=sort(spdiags(flip(pascal(n)))))(~~M)(n)
```
1-based.
[**Try it online!**](https://tio.run/##y08uSSxL/Z9mq6en999BI09Tw9e2OL@oRKO4ICUzMb1YIy0ns0CjILE4OTEHKAsCGnV1vppA9v/EoqLEyrTSPI00HQVDK0NTzf8A "Octave – Try It Online")
### Explanation
Consider `n=4` as an example.
`pascal(n)` gives a Pascal matrix:
```
 1     1     1     1
 1     2     3     4
 1     3     6    10
 1     4    10    20
```
The rows of the Pascal triangle are the antidiagonals of this matrix. So it is flipped vertically using `flip(···)`
```
 1     4    10    20
 1     3     6    10
 1     2     3     4
 1     1     1     1
```
which transforms antidiagonals into diagonals.
`spdiags(···)` extracts the (nonzero) diagonals, starting from lower left, and arranges them as zero-padded columns:
```
 1     1     1     1     0     0     0
 0     1     2     3     4     0     0
 0     0     1     3     6    10     0
 0     0     0     1     4    10    20
```
`M=sort(···)` sorts each column of this matrix, and assigns the result to variable `M`:
```
 0     0     0     1     0     0     0
 0     0     1     1     4     0     0
 0     1     1     3     4    10     0
 1     1     2     3     6    10    20
```
Logical indexing `(···)(~~M)` is now used to extract the nonzeros of this matrix in column-major order (down, then across). The result is a column vector:
```
 1
 1
 1
 1
···
10
10
20
```
Finally, the `n`-th entry of this vector is extracted using `(···)(n)`, which in this case gives `1`.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~86~~ ~~78~~ 72 bytes
-8 bytes thanks to [Rod](https://codegolf.stackexchange.com/users/47120/rod)
```
g=lambda n,r=[1]:r[n:]and r[n/2]or g(n-len(r),map(sum,zip([0]+r,r+[0])))
```
[Try it online!](https://tio.run/##DcsxCsMwDEDRq2iUiEqdQJdATmI8qCR1BbFi1HRoL@94@m/59Xe@D5tay8su5bkKGPsSxzR7tDmJrdBxn9LhkNFu@2boxEUqfr6F/1oxhjQ4@9BLRK262hkzKr36o6AGLpY3DAyPQKld "Python 2 – Try It Online")
## Ungolfed
```
def g(n, row=[1]):
  if n < len(row):
    return row[n/2]
  else:
    next_row = map(sum, zip([0] + row, row + [0]))
    return g(n - len(row), next_row)
```
[Try it online!](https://tio.run/##TY3NCsIwEITvPsUcE4wYC17EPkkIUnBbA@02pCn@vHzcVijelm9m54vv/Bi5KuVOLTrFBml81u7k9WUHhBaMK3piJXhFQKI8J156jo@VF0b9RL@M6ZVvkqDG0EQ1zYPBJ0TlrMd@eVn35RSg9f@cuHHYTGZb0iWmwBmuU0GjHRMCgtgb7khZg7PVvnwB "Python 2 – Try It Online")
The function recursively calculates the row of Pascal's Triangle. Given the current row as `row`, `map(sum, zip([0] + row, row + [0]))`.  
At each call `n` is reduced by the length of the current row. If the function arrives at the right row the `nth` lowest number of the row should be returned.  
As the first half of a row is in ascending order and each row is symmetrical, the number is at index `n/2` (0-indexed, integer division). 
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 55 bytes
The indexing is 1-based.
```
(##&@@@Sort/@Table[n~Binomial~k,{n,0,#},{k,0,n}])[[#]]&
```
[Try it online!](https://tio.run/##DcVNCoMwEAbQwwRE4QMdtT8uCkNPILS7kMW0KA2aCJJdiFePfZvnJPwmJ8F@Jc@PXCpVMPNr20PNb/msk/bH0/rNWVmPBdGjgUqIy3@fTKW1MqbI42594HKuORJadOhxwRU33DGAGhCBWlAH6lOVTw "Wolfram Language (Mathematica) – Try It Online")
## Explanation
This is likely golfable, I am not a very experienced Mathematica user.
```
Table[n~Binomial~k,{n,0,#},{k,0,n}]
```
For each **n ∈ [0, Input] ∩ ℤ**, generate the table of binomials with each **k ∈ [0, n] ∩ ℤ**.
```
Sort/@
```
Sort each. Uses a shorthand to `Map[function,object]` – `function/@object`.
```
(##&@@@...)[[#]]
```
Flatten the resulting list and retrieve the element whose index in the list is the input.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), ~~26~~ 25 bytes
*1 byte saved thanks to @ngn*
```
{⍵⊃0~⍨∊(⍋⊃¨⊂)¨↓⍉∘.!⍨⍳1+⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/9OAZPWj3q2PupoN6h71rnjU0aXxqLcbyD204lFXkyaQbJv8qLfzUccMPUWQfO9mQ22g@tr//9MOgXhGBgA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 58 bytes
```
function(n)(m=apply(outer(0:n,0:n,choose),1,sort))[m>0][n]
```
[Try it online!](https://tio.run/##K/qfpmCj@z@tNC@5JDM/TyNPUyPXNrGgIKdSI7@0JLVIw8AqTweEkzPy84tTNXUMdYrzi0o0NaNz7Qxio/Ni/xdDVBtaGRnopGn@BwA "R – Try It Online")
Computes `n choose k` for each `n,k` in `[0,1,...,n]` as a matrix, sorts the rows ascending(\*), and removes the zeros, then selects the `n`th element.
(\*) This also transforms them into *columns* but that's better since R stores a matrix as a vector columnwise, which allows us to index directly into it while preserving order.
[Answer]
# [Haskell](https://www.haskell.org/), ~~143~~ ~~132~~ ~~125~~ 123 bytes
```
((p>>=s.h)!!)
p=[1]:map(\r->zipWith(+)(0:r)(r++[0]))p
h r=splitAt(div(length r)2)r
s(a,b)=reverse b!a
(h:t)!b=h:(b!t)
x!_=x
```
The first line is a point-free function that takes an index (0-based) and returns the appropriate number in the sequence. [Try it online!](https://tio.run/##Dc0xDoMgFADQnVPA9n@sxjqSYNJTdFDTgEUhRfMDxJgevtT1Lc/p9LEhlEWNBYD6XqXGoRDISA33SW6aYIx1//X09NlBhdDKiBCramgnRGKOR5Uo@PzI8PYHBLuv@ULsMLIE@mZQRXvYmCw3QjNwMqMwykkwIiM7xUudZdN@54pT9HvmcK184UPbNN2VlN@8BL2mUs9Efw "Haskell – Try It Online")
This is my first ever Haskell program! I'm sure it can get much shorter. Tips are appreciated.
*Saved 2 bytes thanks to [nimi](https://codegolf.stackexchange.com/users/34531/nimi)*
### Ungolfed
```
pascalRows = [1] : map (\row -> zipWith (+) (0:row) (row++[0])) pascalRows
halves row = splitAt (div (length row) 2) row
joinSorted (first, second) = interleave (reverse second) first
interleave [] _ = []
interleave longer shorter = (head longer) : (interleave shorter (tail longer))
f n = (concatMap (joinSorted.halves) pascalRows) !! n
```
[Answer]
# JavaScript, 57 bytes
```
f=(i,r=1)=>i<r?i>1?f(i-2,--r)+f(i<r?i:r-1,r):1:f(i-r,r+1)
```
0-indexed.
How does this come:
Step 0:
```
c=(i,r)=>i?r&&c(i-1,r-1)+c(i,r-1):1
f=(i,r=1)=>i<r?c(i>>1,r-1):f(i-r,r+1)
```
This code is easy to understand:
* function `c` calculate the Combination use formula: C(n,k) = C(n-1,k) + C(n-1,k-1); or 1 if k == 0 or k == n
* function `f` try to find out the row number and index in the row, and then call function c for getting the result.
Step 1:
```
c=(i,r)=>i>1?--r&&c(i-2,r)+c(i,r):1
f=(i,r=1)=>i<r?c(i,r):f(i-r,r+1)
```
In this step, we try to modify the call of function `c` to `c(i,r)` which makes it as same as parameter of `f`.
Step 2:
```
c=(i,r)=>i>1?--r&&c(i-2,r)+c(i<r?i:r-1,r):1
f=(i,r=1)=>i<r?c(i,r):f(i-r,r+1)
```
We test `i<r` for whether using function `f` or function `c`. That's why we musk keep `i<r` holds during recursion of function `c`.
Step 3:
```
f=(i,r=1)=>i<r?i>1?--r&&f(i-2,r)+f(i<r?i:r-1,r):1:f(i-r,r+1)
```
At this step, we merge these two function into one.
After some more golf, we finally got the answer described above.
```
f=(i,r=1)=>i<r?i>1?f(i-2,--r)+f(i<r?i:r-1,r):1:f(i-r,r+1)
for(i=0,x=1;x<10;x++) {
document.write('<p>')
for(j=0;j<x;j++,i++) document.write(`<b>${f(i)}</b>`)
}
```
```
p { text-align: center; }
b { display: inline-block; width: 4ch; font-weight: normal; }
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 bytes
```
0rcþ`ZṢ€Ẏḟ0⁸ị
```
[Try it online!](https://tio.run/##ASYA2f9qZWxsef//MHJjw75gWuG5ouKCrOG6juG4nzDigbjhu4v///8xNQ "Jelly – Try It Online")
Using Uriel's Dyalog algorithm.
1-indexed.
Explanation:
```
0rcþ`ZṢ€Ẏḟ0⁸ị
0r            Return inclusive range from 0 to n
    `         Call this dyad with this argument on both sides
   þ           Outer product with this dyad
  c             Binomial coefficient
     Z        Zip
       €      Call this link on each element
      Ṣ        Sort
        Ẏ     Concatenate elements
         ḟ0   Remove 0s
           ⁸ị Take the nth element
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 17 bytes
```
⎕⊃∊i!⍨,\⌊.5×i←⍳99
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob2pm/qO2CQZcjzra00DcR13Njzq6MhUf9a7QiXnU06Vnenh6JlDFo97Nlpb/gar@p3EZcKVxGQKxERAbA7EJEJsCsRkQmwOxBRBbgtSAFYJUGoKUGoLUGoIUG5oCAA "APL (Dyalog Classic) – Try It Online")
0-based indexing
note that `(49!98) > 2*53`, i.e. the binomial coefficient 98 over 49 is greater than 253, so at that point Dyalog has already started losing precision because of IEEE floating point
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 65 bytes
Not even an array is used. 0-indexed.
```
f=(n,i=0,g=x=>x?x*g(x-1):1)=>n>i?f(n-++i,i):g(i)/g(c=n>>1)/g(i-c)
```
[Try it online!](https://tio.run/##Fc1LDoIwFEbh7bTyF7k85GFaFmIckArNNdgSMaa7rzg7@SbnOX2n3b55@ygfHnNKixYerAs4HbWJYzw5ERXJgaQ23vC4CK@yjMFycILl2QmrvTH0L1ZWpqsNfg/rnK/BiVsBQokKNRpc0KJDDzqQQCWoAtWgBnQBtaAO1KMs7vlr2gRrsxwDKdMP "JavaScript (Node.js) – Try It Online")
Explanation:
```
f=(n,i=0,                 )=>                                     // Main Function
         g=x=>x?x*g(x-1):1                                        // Helper (Factorial)
                             n>i?                                 // Is n > i?
                                 f(n-++i,i):                      // If so, call function
                                                                  // f(n-i-1, i+1) to skip
                                                                  // . i+1 terms
                                            g(i)/g(c=n>>1)/g(i-c) // If not, since sorting 
                                                                  // . the binomial coeffs
                                                                  // . equals to writing
                                                                  // . the first floor(i/2)
                                                                  // . coefficients twice
                                                                  // . each, so a shortcut
```
[Answer]
# [Pascal](https://www.freepascal.org/), 373 bytes
```
function t(n,k,r:integer):integer;begin if(n<k)then t:=r-1 else t:=t(n,k+r,r+1)end;
function s(n,k:integer):integer;begin if(k=0)then s:=n else s:=s(n+k,k-1)end;
function f(n,k:integer):integer;begin if((k<1)or(k>n))then f:=0 else if n=1 then f:=1 else f:=f(n-1,k-1)+f(n-1,k)end;
function g(n:integer):integer;var k:integer;begin k:=t(n,0,1);g:=f(k,(n-s(0,k-1)+2)div 2)end;
```
`g` is the function.
[Try it online!](https://tio.run/##hdDBbsMgDAbge5/CR1DIFNobNHuXNAGG6EzksO7xUwjNDpm0XdAvgz9bzMMyDvfWzuM6U3Q0fMK8lfRqv3BMPiIkhiIIUh6TcYb4HvTNOI/gLcNr4OnD5Keqp1aCuS@m5K2zIUGN5AYnffoxl3Lzhxj6roqL6rF6OeWuJojQHjX7j8bCVfJILLwjr6xVfVdZbwF7CXv1tXxOGW3lNqx5xcNUx/D3zMdAEA4bhPoTnZBcuwIHkcGFdVU/88k/4Lzpa@n3CnbgVAUbSzWvnCJcOpgi1Po3@WSYY56rC9ew7ZePt/UJ "Pascal (FPC) – Try It Online")
[Answer]
# Java 8, 187 bytes
```
n->{int r=~-(int)Math.sqrt(8*n+1)/2+1,a[]=new int[r],k=r,x=0;for(;k-->0;a[k]=p(r,k))x+=k;java.util.Arrays.sort(a);return a[n-x];}int p(int r,int k){return--r<1|k<2|k>r?1:p(r,k-1)+p(r,k);}
```
**Explanation:**
[Try it online.](https://tio.run/##LZBNbsIwEIX3nGLEKm7iQJAqVTWh6gFgwzLKwg0GjBM7nUwoCNKrpzZU8o9mxnp@7zvJs@SuVfa0M2NVy66DtdT2NgHQlhTuZaVgE0qA2tkDVJHvg2XCtwa//dqAhRxGy1e3MMP8l4dHbC3pmHbfSNHbi40zNlvEWSKLMrfqJ6gXWCYmx@SSz8XeYSQM56u5kIUp8zbCxDB2iXMjTt5j2pOu009Eee3SznlNyQQq6tGCLCy/lGKYiOByNoONI2glErg90FHB15UUr1xvaRIMto8ImITTsNtThXNcZnezXNzNCj@y94cBnrH46UQMI0Dbf9W6go4k@evs9A4aDyvaEmp7KEqQ7EkqIITGQwlJQxE9eAGEmOFb7SPr5as/4pg9JgDba0eqSV1Paev1KGpSm3rcLJ4m03/ew/gH)
```
n->{                   // Method with integer as both parameter and return-type
  int r=~-(int)Math.sqrt(8*n+1)/2+1,
                       //  Calculate the 1-indexed row based on the input
      a[]=new int[r],  //  Create an array with items equal to the current row
      k=r,             //  Index integer
      x=0;             //  Correction integer
  for(;k-->0;          //  Loop down to 0
    a[k]=p(r,k))       //   Fill the array with the Pascal's Triangle numbers of the row
    x+=k;              //   Create the correction integer
  java.util.Arrays.sort(a);
                       //  Sort the array
  return a[n-x];}      //  Return the `n-x`'th (0-indexed) item in this sorted array
// Separated recursive method to get the k'th value of the r'th row in the Pascal Triangle
int p(int r,int k){return--r<1|k<2|k>r?1:p(r,k-1)+p(r,k);}
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 11 bytes
```
:qt!XnSXzG)
```
1-based.
[Try it online!](https://tio.run/##y00syfn/36qwRDEiLziiyl3z/39LAA "MATL – Try It Online") Or [verify all test cases](https://tio.run/##y00syfmv5PDfqrBEMSIvOKLKQfP/f0MrQ1MA).
### Explanation
Consider input `4` as an example. `;` is the row separator for matrices or column vectors.
```
:     % Implicit input: n. Push the row vector [1 2 ... n]          
      S STACK: [1 2 3 4]
q     % Subtract 1, emlement-wise: gives [0 1 ... n-1]
      % STACK: [0 1 2 3]
t!    % Duplicate and transpose into a column vector
      % STACK: [0 1 2 3], [0; 1; 2; 3]
Xn    % Binomial coefficient, element-wise with broadcast. Gives an
      % n×n matrix where entry (i,j) is binomial(i,j), or 0 for i<j
      % STACK: [1 1 1 1;
                0 1 2 3;
                0 0 1 3;
                0 0 0 1]
S     % Sort each column
      % STACK: [0 0 0 1;
      %         0 0 1 1;
      %         0 1 1 3;
      %         1 1 2 3]
Xz    % Keep only nonzeros. Gives a column vector
      % STACK: [1; 1; 1; 1; 1; 2; 1; 1; 3; 3]
G)    % Get the n-th element. Implicitly display
      % STACK: 1
```
[Answer]
## Batch, 128 bytes
```
@set/as=2,t=r=m=i=1
:l
@if %1 geq %t% set/as+=r,t+=r+=1&goto l
@for /l %%i in (%s%,2,%1)do @set/ar-=1,m=m*r/i,i+=1
@echo %m%
```
0-indexed.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 10 bytes
0-indexed
```
ÝεDÝc{}˜sè
```
[Try it online!](https://tio.run/##MzBNTDJM/f//8NxzW10Oz02urj09p/jwiv//DU0A "05AB1E – Try It Online")
**Explanation**
```
Ý             # push range [0 ... input]
 ε    }       # apply to each element
  DÝc         # N choose [0 ... N]
     {        # sort
       ˜      # flatten result to a list
        sè    # get the element at index <input>
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
Ḷc€`Ṣ€Fḟ0ị@
```
**[Try it online!](https://tio.run/##y0rNyan8///hjm3Jj5rWJDzcuQhIuT3cMd/g4e5uh////1sCAA "Jelly – Try It Online")**
A monadic link taking the index and returning an integer - uses 1-based indexing.
### How?
Performs the challenge pretty much just as it is written, just with more of the right of Pascal's triangle (zeros) which is then thrown away...
```
Ḷc€`Ṣ€Fḟ0ị@ - Link: integer, i    e.g. 1   or    9
Ḷ           - lowered range            [0]       [0,1,2,3,4,5,6,7,8]
   `        - repeat left as right arg [0]       [0,1,2,3,4,5,6,7,8]
 c€         - binomial choice for €ach [[1]]     [[1,0,0,0,0,0,0,0,0],[1,1,0,0,0,0,0,0,0],[1,2,1,0,0,0,0,0,0],[1,3,3,1,0,0,0,0,0],[1,4,6,4,1,0,0,0,0],[1,5,10,10,5,1,0,0,0],[1,6,15,20,15,6,1,0,0],[1,7,21,35,35,21,7,1,0],[1,8,28,56,70,56,28,8,1]]
    Ṣ€      - sort €ach                [[1]]     [[0,0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,1,1],[0,0,0,0,0,0,1,1,2],[0,0,0,0,0,1,1,3,3],[0,0,0,0,1,1,4,4,6],[0,0,0,1,1,5,5,10,10],[0,0,1,1,6,6,15,15,20],[0,1,1,7,7,21,21,35,35],[1,1,8,8,28,28,56,56,70]]
      F     - flatten                  [1]       [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,2,0,0,0,0,0,1,1,3,3,0,0,0,0,1,1,4,4,6,0,0,0,1,1,5,5,10,10,0,0,1,1,6,6,15,15,20,0,1,1,7,7,21,21,35,35,1,1,8,8,28,28,56,56,70]
       ḟ0   - filter discard zeros     [1]       [1,1,1,1,1,2,1,1,3,3,1,1,4,4,6,1,1,5,5,111,1,6,6,15,15,21,1,7,7,21,21,35,35,1,1,8,8,28,28,56,56,70]
         ị@ - index into (sw@p args)    1         3 --------------^
```
[Answer]
# [Red](http://www.red-lang.org), 206 bytes
```
f: func[n][t: copy[[1]]l: 0
while[l < n][a: copy last t insert append a 0 0 b: copy[]repeat i k:(length? a)- 1[append b a/(i) + a/(i + 1)]append t reduce[b]l: l + k]foreach p t[sort p]pick split form t{ }n]
```
1-based
[Try it online!](https://tio.run/##PY7BasMwEETv@Yohp5hSaht6EYX@Q67LHmR5XQurspAVSgj5dmfbiLKHGfYNO5tl3M8ygnifDKZLdBSZioFb05WoYw4G7eFn9kEo4ANK7ZMi2K2gwMdNcoFNSeIIi1ZnqAc4SxKrGSzmFCR@lfkTtnlFRzU/wL6dfIOXP1XpGq6oIMt4cULD7xNB2cLTmsW6GQmFtlVrEyfvFmwp@AKl3yg33CPv/819C0LKPhZVj6M5YlJl8OG5vd2rof69r1wd7w8 "Red – Try It Online")
## Explanation:
```
f: func [n] [
    t: copy [[1]]                       ; start with a list with one sublist [1]
    l: 0                                ; there are 1 items overall
    while [l < n] [                     ; while the number of items is less than the argument
        a: copy last t                  ; take the last sublist 
        insert append a 0 0             ; prepend and append 0 to it  
        b: copy []                      ; prepare a list for the sums  
        repeat i k: (length? a) - 1 [   ; loop throught the elements of the list
            append b a/(i) + a/(i + 1)] ; and find the sum of the adjacent items
        append t reduce [b]             ; append the resulting list to the total list
        l: l + k                        ; update the number of the items
    ]
    foreach p t [sort p]                ; sort each sublist
    v: pick split form t { } n          ; flatten the list and take the n-th element
]
```
[Answer]
# Perl, 48 bytes
Includes `+1` for `p`
```
perl -pe '$_-=$%until$_<++$%;$./=$_/--$%for 1..$_/2;$_=$.' <<< 19
```
Uses base 0 indexing.
[Answer]
# [Julia](https://julialang.org), 70 bytes
```
f(x)=map(n->binomial(n-1,ceil(Int,x/2-(n^2-n)/4-1)),round(Int,√(x*2)))
```
1-based
Explanation:
it first find the row number, then the column number, then compute the binomial
[Answer]
# [J](http://jsoftware.com/), ~~43~~ 38 bytes
```
](([-2!]){/:~@(i.!<:)@])[:<.2&!@,:^:_1
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WgrqCjYKBgBcS6egrOQT5u/2M1NKJ1jRRjNav1reocNDL1FG2sNB1iNaOtbPSM1BQddKzirOIN/2typSZn5CukKRkoZOopGBv8BwA "J – Try It Online")
0-indexed
Notes:
* `<.2&!@,:^:_1` gives the relevant row number of Pascal's triangle by rounding down the inverse of `y choose 2`.
* `/:~@(i.!<:)@]` calculates the row and sorts it.
* `[-2!]` gives the index into the row.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 9 bytes
```
ʀƛʀƈs;f$i
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%CA%80%C6%9B%CA%80%C6%88s%3Bf%24i&inputs=5&header=&footer=)
No efficiency at all. 0-indexed.
```
ʀ         # 0...n
 ƛ   ;    # Mapped to...
  ʀ       # 0...n
   ƈ      # Binomial coefficient with n, vectorised
    s     # Sort these
      f   # Flatten
       $i # Index input into this.
```
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2), 8 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
ĖDȷc€ṠḞi
```
[Try it online!](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPSVDNCU5NkQlQzglQjdjJUUyJTgyJUFDJUUxJUI5JUEwJUUxJUI4JTlFaSZmb290ZXI9JmlucHV0PTE0JmZsYWdzPQ==)   
or [see the interpreter complaining](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPSVDNCU5NkQlQzglQjdjJmZvb3Rlcj0maW5wdXQ9NSZmbGFncz13) (explained below)
#### Explanation
```
ĖDȷc€ṠḞi  # Implicit input
Ė         # Push [0..input]
 Dȷc      # Outer product over ncr with itself
          # NOTE: the interpreter actually tries to calculate all the
          #       values: [0C0, 0C1, 0C2, ..., (input)C(input)], but
          #       fails for the ones where r > n. It silently carries
          #       on, ignoring those values, so we end up with input+1
          #       rows of Pascal's triangle :D. However, if you add
          #       the w (warnings) flag, you'll see all the errors
          #       which were caught by the interpreter (link above)
    €Ṡ    # Sort each row of the triangle
      Ḟ   # Flatten the list of lists
       i  # Index in using the input
          # Implicit output
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `M`, 7 bytes
```
ƛʀƈs;fi
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJNIiwiIiwixpvKgMaIcztmaSIsIiIsIjE0Il0=)
#### Explanation
```
ƛʀƈs;fi  # Implicit input
ƛ   ;    # Map over [0..input]
 ʀƈ      #  nCr with each of [0..that]
   s     #  Sort the resulting list
     f   # Flatten the list of lists
      i  # Index in using the input
         # Implicit output
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 17 bytes
```
1+2\1,1j$$Ð¡Ṣ€Ẏ⁸ị
```
[Try it online!](https://tio.run/##y0rNyan8/99Q2yjGUMcwS0Xl8IRDCx/uXPSoac3DXX2PGnc83N39HyhvCgA "Jelly – Try It Online")
[Answer]
# Pyth, 15 bytes
```
@u+GSm.cHdhHhQY
```
0-indexed
[Try it](http://pyth.herokuapp.com/?code=%40u%2BGSm.cHdhHhQY&input=5&debug=0)
### Explanation
```
@u+GSm.cHdhHhQY
 u          hQY   Reduce on [0, ..., input], starting with the empty list...
  +G              ... append to the accumulator...
    Sm.cHdhH      ... the sorted binomial coefficients.
@              Q  Take the 0-indexed element.
```
[Answer]
# [Clean](https://clean.cs.ru.nl), 80 bytes
```
import StdEnv
```
# 
```
\n=flatten[sort[prod[j+1..i]/prod[1..i-j]\\j<-[0..i]]\\i<-[0..]]!!n
```
[Try it online!](https://tio.run/##JY2xDsIgGIT3PgWNo6HSXTYdTNw6AgMBaiDwQwBNfHkRdPvucvlOeSOhhaif3qAgLTQbUswVbVVf4dW2KnOdDmhHFHGgu5e1GmClT1jKUTN3XJfFitMvDMROcO7OmJHRd7Z/FmKeYaL9JHXbaFZCRPuo7nyUhm/3dnmDDFaVLw "Clean – Try It Online")
As a lambda function.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 56 bytes
```
->n{a=0;n-=a until n<a+=1;[*2..a].combination(n/2).size}
```
0-based
First get the row and column in the triangle, then calculate the binomial coefficient corresponding to that position.
[Try it online!](https://tio.run/##BcHRDkAgFADQX@lRzBWbp@RHrIfL2Nq4NWpD@vacc4b5yZvK9UgRlZBUK2SBvNkZDVipVk5lB4AaFnvMhtAbSwU1HYfLvGvKjhUCoBccDnTxu79tunXKPw "Ruby – Try It Online")
[Answer]
# [Actually](https://github.com/Mego/Seriously), 8 bytes
Largely based on [Jonathan Allan's Jelly answer](https://codegolf.stackexchange.com/a/155168/47581). Uses 0-indexing.
```
;r♂╣♂SΣE
```
[Try it online!](https://tio.run/##S0wuKU3Myan8/9@66NHMpkdTFwPJ4HOLXf//NzQBAA "Actually – Try It Online")
**Ungolfing**
```
          Implicit input n.
;         Duplicate n.
 r        Lowered range. [0..n-1].
  ♂╣      Pascal's triangle row of every number.
    ♂S    Sort every row.
      Σ   Sum each row into one array.
       E  Get the n-th element of the array (0-indexed).
          Implicit return.
```
[Answer]
# [Coconut](http://coconut-lang.org/), 69 bytes
```
def g(n,r=[1])=r[n:]and r[n//2]or g(n-len(r),[*map((+),[0]+r,r+[0])])
```
[Try it online!](https://tio.run/##FYtBCoAwDAS/kmNiK1bBi@BLSg5FayloKkHfX@tpBmZ3K1uR96l1jwckFKurH5lW9bJwkB2aDMPERf/an1FQyfruCjeiaebYqFXTSEz11iwP@oSZjnbJkAU0SIroLMzun3w "Coconut – Try It Online")
]