[Question]
  [
### Challenge
Given a nonempty list of real numbers, compute its median.
### Definitions
The median is computed as follows: First sort the list,
* if the number of entries is *odd*, the median is the value in the center of the sorted list,
* otherwise the median is the arithmetic mean of the two values closest to the center of the sorted list.
### Examples
```
[1,2,3,4,5,6,7,8,9] -> 5
[1,4,3,2] -> 2.5
[1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,-5,100000,1.3,1.4] -> 1.5
[1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,-5,100000,1.3,1.4] -> 1.5
```
  
[Answer]
# [Python 2](https://docs.python.org/2/), 48 bytes
An unnamed function which returns the result. -1 byte thanks to xnor.
```
lambda l:l.sort()or(l[len(l)/2]+l[~len(l)/2])/2.
```
The first step is obviously to sort the array, using `l.sort()`. However, we can only have one statement in a lambda, so we utilise the fact that the sort function returns `None` by adding an `or` - as `None` is falsy in Python, this tells it to evaluate and return the next part of the statement.
Now we have the sorted list, we need to find either the middle, or the middle two, values.
Using a conditional to check the length's parity would be too verbose, so instead we get the indexes `len(l)/2` and `~len(l)/2`:
* The first is **floor(length / 2)**, which gets the middle element if the length is odd, or the left item in the central pair if the length is even.
* The second is the binary inversion of the list length's, evaluating to **-1 - floor(length / 2)**. Due Python's negative indexing, this essentially does the same as the first index, but backwards from the end of the array.
If the list is of odd length, these indexes will point to the same value. If it is of even length, then they will point to the central two items.
Now that we have these two indexes, we find these values in the list, sum them, and divide them by 2. The trailing decimal place in `/2.` makes sure that it is float division rather than integer division.
The result is implicitly returned, as this is a lambda function.
[**Try it online!**](https://tio.run/nexus/python2#@5@mYKuQk5iblJKokGOVo1ecX1SioZlfpJETnZOap5GjqW8Uq50TXQfnALHe/4KizLwSjTSNzLyCUqByTc3/0YY6JjpGOsax/wE)
[Answer]
# Python3 - ~~31~~ 30 bytes
*Saved a byte thanks to @Dennis!*
I wasn't planning on a builtin answer, but I found [this module](https://docs.python.org/3/library/statistics.html) and thought it was really cool cuz I had no idea it existed.
```
from statistics import*;median
```
[Try it online here](http://vihan.org/p/tio/?l=python3&p=KyjKzCvRiI/PzC3ILyqJj9dQLy5JLMksLslMLlbX1MtNTclMzNNILUvM0cjMKygt0dAEgv/RhnqmOoSwLpAyAAEgzxiITWIB).
[Answer]
## [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
L‘HịṢµ÷LS
```
[Try it online!](https://tio.run/nexus/jelly#AR4A4f//TOKAmEjhu4vhuaLCtcO3TFP///9bMSw0LDMsMl0 "Jelly – TIO Nexus")
### Explanation
I'm still getting the hang of Jelly... I wasn't able to find built-ins for either the median or the mean of a list, but it's very convenient for this challenge that Jelly allows non-integer indices into lists, in which case it will return a pair of the two closest values. That means we can work with half the input length as an index, and get a pair of values when we need to average it.
```
L          Get the length of the input.
 ‘         Increment it.
  H        Halve it. This gives us the index of the median for an odd-length list
           (Jelly uses 1-based indexing), and a half-integer between the two indices
           we need to average for even-length lists.
   ịṢ      Use this as an index into the sorted input. As explained above this will
           either give us the median (in case of an odd-length list) or a pair of
           values we'll now need to average.
     µ     Starts a monadic chain which is then applied to this median or pair...
      ÷L     Divide by the length. L treats atomic values like singleton lists.
        S    Sum. This also treats atomic values like singleton lists. Hence this
             monadic chain leaves a single value unchanged but will return the
             mean of a pair.
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 914 + 1 = 915 bytes
```
([]){({}[()]<(([])<{({}[()]<([([({}<(({})<>)<>>)<><({}<>)>]{}<(())>)](<>)){({}())<>}{}({}<><{}{}>){{}<>(<({}<({}<>)<>>)<>({}<>)>)}{}({}<>)<>>)}{}<>{}>[()]){({}[()]<({}<>)<>>)}{}<>>)}{}([]<(()())>(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{}<(())>){((<{}{}([[]]()){({}()()<{}>)}{}(({}){}<([]){{}{}([])}{}>)>))}{}{(<{}([[]]()()){({}()()<{}>)}{}({}{}<([]){{}{}([])}{}>)>)}{}([(({}<((((((()()()){}){}){}()){})[()()()])>)<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}(({}<>)<{(<{}([{}])>)}{}{(({})<((()()()()()){})>)({}(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{})({}<({}<>)<>>((((()()()){}){}){}){})((()()()()()){})<>({}<>)(()()){({}[()]<([([({})](<()>))](<>())){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}(({})<>)<>{(<{}([{}])>)}{}({}<>)<>({}<><({}<>)>)>)}{}({}(<>))<>([()]{()<(({})){({}[()])<>}{}>}{}<><{}{}>)<>(({}{}[(())])){{}{}(((<{}>)))}{}{}{(<{}<>([{}])><>)}{}<>}{}>){(<{}(((((()()()()())){}{})){}{})>)}{}
```
Requires the `-A` flag to run.
[Try it online!](https://tio.run/nexus/brain-flak#lVNbasQwDLyKP6WPfDR9QMAYeg6jkxifPdVo5H2RQrubbCxbI81MtKd00yFjdlGrgqjew@7fMX17TK3NL9wVW02bxYlqUxOPo4qHtU1/IqUOXzUdWEugiGSZrKIrO7YnVg5C@wdaz@fEdNBV9I/uDguaNxSJBEA6mN35emZwk97NZDEXVz5ZG4WQDW@YaBpavJE/B@AJvoIDcgmOSGhpfJQFJi8uO3fN83/1FyaFMkrOINNTASxLpmMa9@lRXZ1X96ao/Wcb9eldXgjB9dpjvXG5efY4Y9AosBda/fzfajmfr3oXSc7jGrl1lIoFRIZovVLO/jnKpIBjb21JRWKavFIYzOGgWU6i5szynxDs7n6FEwpQ/kbyeX6Vj7If5e0oe9k@y7aXo2zvvndu3z8 "Brain-Flak – TIO Nexus")
# Explanation
The backbone of this algorithm is a bubble sort I wrote a while ago.
```
([]){({}[()]<(([])<{({}[()]<([([({}<(({})<>)<>>)<><({}<>)>]{}<(())>)](<>)){({}())<>}{}({}<><{}{}>){{}<>(<({}<({}<>)<>>)<>({}<>)>)}{}({}<>)<>>)}{}<>{}>[()]){({}[()]<({}<>)<>>)}{}<>>)}{}
```
I don't remember how this works so don't ask me. But I do know it sorts the stack and even works for negatives
After everything has been sorted I find 2 times the median with the following chunk
```
([]<(()())>(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{}<(())>)  #Stack height modulo 2
{((<{}{}          #If odd
 ([[]]())         #Push negative stack height +1
 {                #Until zero 
  ({}()()<{}>)    #add 2 to the stack height and pop one
 }{}              #Get rid of garbage
 (({}){}<         #Pickup and double the top value
 ([]){{}{}([])}{} #Remove everything on the stack
 >)               #Put it back down
>))}{}            #End if
{(<{}                     #If even
  ([[]]()())              #Push -sh + 2
  {({}()()<{}>)}{}        #Remove one value for every 2 in that value
  ({}{}<([]){{}{}([])}{}>)#Add the top two and remove everything under them
>)}{}                     #End if
```
Now all that is left is to make convert to ASCII
```
([(({}<((((((()()()){}){}){}()){})[()()()])>)<(())>)](<>)){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}(({}<>)<
{(<{}([{}])>)}{}  #Absolute value (put "/2" beneath everything)
{                 #Until the residue is zero 
(({})<            #|Convert to base 10
((()()()()()){})  #|
>)                #|...
({}(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{})
({}<({}<>)<>>((((()()()){}){}){}){})((()()()()()){})<>({}<>)
                  #|
(()()){({}[()]<([([({})](<()>))](<>())){({}())<>}{}<>{}{}<>(({})){{}{}<>(<(())>)}{}(({})<>)<>{(<{}([{}])>)}{}({}<>)<>({}<><({}<>)>)>)}{}({}(<>))<>([()]{()<(({})){({}[()])<>}{}>}{}<><{}{}>)<>(({}{}[(())])){{}{}(((<{}>)))}{}{}{(<{}<>([{}])><>)}{}<>
}{}               #|
>)
{(<{}(((((()()()()())){}{})){}{})>)}{}  #If it was negative put a minus sign
```
[Answer]
# [Actually](https://github.com/Mego/Seriously), 1 byte
```
║
```
[Try it online!](https://tio.run/nexus/actually#@/9o6sT//6MN9Ux1CGFdIGUAAkCeMRCbxAIA "Actually – TIO Nexus")
[Answer]
# R, 6 bytes
```
median
```
Not surprising that R, a statistical programming language, has this built-in.
[Answer]
# Matlab/Octave, 6 bytes
A boring built-in:
```
median
```
[Try it online!](https://tio.run/nexus/octave#@5@bmpKZmKcRbahjomOsYxSr@f8/AA "Octave – TIO Nexus")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 14 bytes
```
≢⊃2+/2/⊂∘⍋⌷÷∘2
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24RHnYsedTUbaesb6T/qanrUMeNRb/ejnu2HtwOZRkAlh1ZoGOoY6RjrmOiY6pjpmOtY6FhqAoVMgEJGQIaeqQ4hfGg9kDYAASDXGIhNiNOHQy8A "APL (Dyalog Unicode) – Try It Online")
This is a train. The original dfn was `{(2+/2/⍵[⍋⍵])[≢⍵]÷2}`.
The train is structured as follows
```
┌─┼───┐
≢ ⊃ ┌─┼───┐
    2 / ┌─┼───┐
    ┌─┘ 2 / ┌─┼─┐
    +       ∘ ⌷ ∘
           ┌┴┐ ┌┴┐
           ⊂ ⍋ ÷ 2
```
`⊢` denotes the right argument.
`⌷` index
* `⊂∘⍋` the indices which indexed into `⊢` results in `⊢` being sorted
* `÷∘2` into `⊢` divided by 2
`2/` replicate this twice, so `1 5 7 8` becomes `1 1 5 5 7 7 8 8`
`2+/` take the pairwise sum, this becomes `(1+1)(1+5)(5+5)(5+7)(7+7)(7+8)(8+8)`
`⊃` from this pick
* `≢` element with index equal to the length of `⊢`
Previous solutions
```
{.5×+/(⍵[⍋⍵])[(⌈,⌊).5×1+≢⍵]}
{+/(2/⍵[⍋⍵]÷2)[0 1+≢⍵]}
{+/¯2↑(1-≢⍵)↓2/⍵[⍋⍵]÷2}
{(2+/2/⍵[⍋⍵])[≢⍵]÷2}
{(≢⍵)⊃2+/2/⍵[⍋⍵]÷2}
≢⊃2+/2/2÷⍨⊂∘⍋⌷⊢
≢⊃2+/2/⊂∘⍋⌷÷∘2
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 38 bytes
```
@(x)mean(([1;1]*sort(x))(end/2+[0 1]))
```
This defines an anonymous function. Input is a row vector.
[Try it online!](https://tio.run/nexus/octave#@@@gUaGZm5qYp6ERbWhtGKtVnF9UAhTS1EjNS9E30o42UDCM1dT8n2abmFdszZUGVKVjpGOsY6JjqmOmY65joWMZqwkRNgEKG0E5eqY6hLAukDIAASDPGIhNYjX/AwA "Octave – TIO Nexus")
### Explanation
```
            sort(x)                 % Sort input x, of length k
      [1;1]*                        % Matrix-multiply by column vector of two ones
                                    % This vertically concatenates sort(x) with 
                                    % itself. In column-major order, this effectively 
                                    % repeats each entry of sort(x)
     (             )(end/2+[0 1])   % Select the entry at position end/2 and the next.
                                    % Entries are indexed in column-major order. Since
                                    % the array has 2*k elements, this picks the k-th 
                                    % and (k+1)-th (1-based indexing). Because entries
                                    % were repeated, for odd k this takes the original
                                    % (k+1)/2-th entry twice. For even k this takes
                                    % the original (k/2)-th and (k/2+1)-th entries
mean(                            )  % Mean of the two selected entries
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 4 bytes
```
.5Xq
```
This finds the 0.5-quantile, which is the median.
[Try it online!](https://tio.run/nexus/matl#@69nGlH4/3@0oZ6pDiGsC6QMQADIMwZik1gA "MATL – TIO Nexus")
[Answer]
# Pyth - 11 bytes
Finds the average of the middle item taken both backwards and forwards.
```
.O@R/lQ2_BS
```
[Test Suite](http://pyth.herokuapp.com/?code=.O%40R%2FlQ2_BS&test_suite=1&test_suite_input=%5B1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%5D%0A%5B1%2C4%2C3%2C2%5D%0A%5B1.5%2C1.5%2C1.5%2C1.5%2C1.5%2C1.5%2C1.5%2C1.5%2C1.5%2C-5%2C100000%2C1.3%2C1.4%5D&debug=0).
[Answer]
# JavaScript, 57 52 bytes
```
v=>(v.sort((a,b)=>a-b)[(x=v.length)>>1]+v[--x>>1])/2
```
Sort the array numerically. If the array is an even length, find the 2 middle numbers and average them. If the array is odd, find the middle number twice and divide by 2.
[Answer]
# Mathematica, 6 bytes
```
Median
```
As soon as I figure out [Mthmtca](https://github.com/LegionMammal978/Mthmtca), I'm posting a solution in it.
[Answer]
# [Perl 6](https://perl6.org), 31 bytes
```
*.sort[{($/=$_/2),$/-.5}].sum/2
```
[Try it](https://tio.run/nexus/perl6#hY7BTsMwDIbveQofoiXp3ASydoBKCw/BrVTT1Aap0kqnJUWgaU/EW/BixSkHjrNk2b9/f7In7@Bjq9uCTdS9OB8KxoYvWLVj56CcE@3HU6jPkpuS74xVyE2q80uj/TQYOxfsbTzBoX93Xio4MwCCn7t92EMJ65/vwYhawKPUyZOqQDTCaH889EEKFKr4W@fu8@ja4LqIEJBWAl59QhQQBsRFxQ19BtB7iK/J5YbCf5jaHbvM9S1a3GCGOW7xDu/xoYG0gpyRkZFhF2l1HOgcr2VK5SYGqQ1ltuDk/AI "Perl 6 – TIO Nexus")
## Expanded:
```
*\     # WhateverCode lambda ( this is the parameter )
.sort\ # sort it
[{     # index into the sorted list using a code ref to calculate the positions
  (
    $/ = $_ / 2 # the count of elements divided by 2 stored in ｢$/｣
  ),            # that was the first index
  $/ - .5       # subtract 1/2 to get the second index
                # indexing operations round down to nearest Int
                # so both are effectively the same index if given
                # an odd length array
}]\
.sum / 2        # get the average of the two values
```
[Answer]
# TI-Basic, 2 bytes
```
median(Ans
```
Very straightforward.
[Answer]
# [J](http://jsoftware.com/), ~~16~~ 14 bytes
```
2%~#{2#/:~+\:~
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WgrqCjUGulYKAAxP@NVOuUq42U9a3qtGOs6v5rcqUmZ@QrpCkYKhgrmCqYKRgpmCgYYRH8DwA "J – Try It Online")
In addition to [BMO's array duplication trick](https://codegolf.stackexchange.com/a/173080/78410), I found that we can add the whole array sorted in two directions. Then I realized that the two steps can be reversed, i.e. add the two arrays, *then* duplicate them and take the `n`th element.
### How it works
```
2%~#{2#/:~+\:~
                Input: array of length n
       /:~      Sort ascending
           \:~  Sort descending
          +     Add the two element-wise
     2#         Duplicate each element
   #{           Take n-th element
2%~             Halve
```
---
# Previous answers
## [J](http://jsoftware.com/) with `stats` addon, 18 bytes
```
load'stats'
median
```
[Try it online!](https://tio.run/##y/rv56SnoKSnoJ6mYGulrqCjUGulYKAAxP9z8hNT1ItLEkuK1blyU1MyE/PAajW5UpMz8hUgIgqGCsYKpgpmCkYKJgpGuGT@AwA "J – Try It Online")
Library function FTW.
`median`'s implementation looks like this:
## [J](http://jsoftware.com/), 31 bytes
```
-:@(+/)@((<.,>.)@(-:@<:@#){/:~)
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WuoKNQa6VgoADE/3WtHDS09TUdNDRs9HTs9IAMoIiNlYOyZrW@VZ3mf02u1OSMfIU0BUMFYwVTBTMFIwUTBSMsgv8B "J – Try It Online")
### How it works
```
-:@(+/)@((<.,>.)@(-:@<:@#){/:~)
         (<.,>.)@(-:@<:@#)       Find center indices:
                  -:@<:@#          Compute half of given array's length - 1
          <.,>.                    Form 2-element array of its floor and ceiling
                          {/:~   Extract elements at those indices from sorted array
-:@(+/)                          Sum and half
```
A bit of golfing gives this:
## [J](http://jsoftware.com/), 28 bytes
```
2%~[:+/(<.,>.)@(-:@<:@#){/:~
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WgrqCjUGulYKAAxP@NVOuirbT1NWz0dOz0NB00dK0cbKwclDWr9a3q/mtypSZn5CukKRgqGCuYKpgpGCmYKBhhEfwPAA "J – Try It Online")
[Answer]
## Common Lisp, 89
```
(lambda(s &aux(m(1-(length s)))(s(sort s'<)))(/(+(nth(floor m 2)s)(nth(ceiling m 2)s))2))
```
I compute the mean of elements at position `(floor middle)` and `(ceiling middle)`, where `middle` is the zero-based index for the middle element of the sorted list. It is possible for `middle` to be a whole number, like `1` for an input list of size 3 such as `(10 20 30)`, or a fraction for lists with an even numbers of elements, like `3/2` for `(10 20 30 40)`. In both cases, we compute the expected median value.
```
(lambda (list &aux
             (m (1-(length list)))
             (list (sort list #'<)))
  (/ (+ (nth (floor m 2) list)
        (nth (ceiling m 2) list))
     2))
```
[Answer]
# Vim, 62 bytes
I originally did this in V using only text manipulation until the end, but got frustrated with handling [X] and [X,Y], so here's the easy version. They're about the same length.
```
c$:let m=sort(")[(len(")-1)/2:len(")/2]
=(m[0]+m[-1])/2.0
```
[Try it online!](https://tio.run/nexus/v#@5@swm@Vk1qikGtbnF9UoiGkpBmtkZOaB2LoGmrqG1lBOfpGsVxCthq50Qax2rnRuoaxQBE9g///ow31THUIYV0gZQACQJ4xEJvEAgA "V – TIO Nexus")
Unprintables:
```
c$^O:let m=sort(^R")[(len(^R")-1)/2:len(^R")/2]
^R=(m[0]+m[-1])/2.0
```
Honorable mention:
* `^O` takes you out of insert mode for one command (the let command).
* `^R"` inserts the text that was yanked (in this case the list)
[Answer]
# C#, 126 bytes
```
using System.Linq;float m(float[] a){var x=a.Length;return a.OrderBy(g=>g).Skip(x/2-(x%2==0?1:0)).Take(x%2==0?2:1).Average();}
```
Pretty straightforward, here with LINQ to order the values, skip half the list, take one or two values depending on even/odd and average them. 
[Answer]
# C++ 112 Bytes
Thanks to @original.legin for helping me save bytes.
```
#include<vector>
#include<algorithm>
float a(float*b,int s){std::sort(b,b+s);return(b[s/2-(s&1^1)]+b[s/2])/2;}
```
Usage:
```
    int main()
    {
        int n = 4;
        float e[4] = {1,4,3,2};
        std::cout<<a(e,n); /// Prints 2.5
        n = 9;
        float e1[9] = {1,2,3,4,5,6,7,8,9};
        std::cout<<a(e1,n); /// Prints 5
        n = 13;
        float e2[13] = {1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,-5,100000,1.3,1.4};
        std::cout<<a(e2,n); /// Prints 1.5
        return 0;
    }
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 10 bytes
```
½ΣF~e→←½OD
```
[Try it online!](https://tio.run/##yygtzv6fG5yvnaCtpKBrp6B0Yn3xo6bGokPb/h/ae26xW13qo7ZJj9omHNrr7/L///9oQx0jHWMdEx1THTMdcx0LHctYLqCYCVDMCMTSM9UhhHWBlAEIAHnGQGxCpD7segE "Husk – Try It Online")
### Explanation
This function uses that the median of \$[a\_1 \dots a\_N]\$ is the same as the median of \$[a\_1 \; a\_1 \dots a\_N \; a\_N]\$ which avoids the ugly distinction of odd-/even-length lists.
```
½ΣF~e→←½OD  -- example input: [2,3,4,1]
         D  -- duplicate: [2,3,4,1,2,3,4,1]
        O   -- sort: [1,1,2,2,3,3,4,4]
       ½    -- halve: [[1,1,2,2],[3,3,4,4]]
  F         -- fold the following
   ~        -- | compose the arguments ..
     →      -- | | last element: 2
      ←     -- | | first element: 3
    e       -- | .. and create list: [2,3]
            -- : [2,3]
 Σ          -- sum: 5
½           -- halve: 5/2
```
Unfortunately `½` for lists has the type `[a] -> [[a]]` and not `[a] -> ([a],[a])` which doesn't allow `F~+→←` since `foldl1` needs a function of type `a -> a -> a` as first argument, forcing me to use `e`.
[Answer]
# [Fig](https://github.com/Seggan/Fig), \$11\log\_{256}(96)\approx\$ 9.054 bytes
```
KY
HSt2s{HL
```
[Try it online!](https://fig.fly.dev/#WyJLWVxuSFN0MnN7SEwiLCJbMSw0LDMsMl0iXQ==)
-3 chars because bugfixes
```
KY
HSt2s{HL
--------
KY       # First helper function
 Y       # Interleave with self
K        # Sort
-------- # Send the result to the next function:
HSt2s{HL # Main function
     {HL # Compute len(input)/2-1
    s    # Drop that many items from the input
  t2     # Take 2
 S       # Sum
H        # Halve
```
[Answer]
# J, 19 bytes
```
<.@-:@#{(/:-:@+\:)~
```
Explanation:
```
        (        )~   apply monadic argument twice to dyadic function 
         /:           /:~ = sort the list upwards
               \:     \:~ = sort the list downwards
           -:@+       half of sum of both lists, element-wise
<.@-:@#               floor of half of length of list
       {              get that element from the list of sums
```
[Answer]
# JavaScript, 273 Bytes
```
function m(l){a=(function(){i=l;o=[];while(i.length){p1=i[0];p2=0;for(a=0;a<i.length;a++)if(i[a]<p1){p1=i[a];p2=a}o.push(p1);i[p2]=i[i.length-1];i.pop()}return o})();return a.length%2==1?l[Math.round(l.length/2)-1]:(l[Math.round(l.length/2)-1]+l[Math.round(l.length/2)])/2}
```
[Answer]
# Java 7, 99 bytes
Golfed:
```
float m(Float[]a){java.util.Arrays.sort(a);int l=a.length;return l%2>0?a[l/2]:(a[l/2-1]+a[l/2])/2;}
```
Ungolfed:
```
float m(Float[] a)
{
    java.util.Arrays.sort(a);
    int l = a.length;
    return l % 2 > 0 ? a[l / 2] : (a[l / 2 - 1] + a[l / 2]) / 2;
}
```
[Try it online](https://ideone.com/bEhZOY)
[Answer]
# Pari/GP - 37  ~~39~~  Bytes
Let *a* be a rowvector containing the values.
```
b=vecsort(a);n=#b+1;(b[n\2]+b[n-n\2])/2  \\ 39 byte              
n=1+#b=vecsort(a);(b[n\2]+b[n-n\2])/2    \\ obfuscated but only 37 byte
```
Since Pari/GP is interactive, no additional command is needed to display the result.
---
For the ***"try-it-online"*** link a line before and after is added. To get printed, the median-result in stored in variable *w* 
```
a=vector(8,r,random(999))           
n=1+#b=vecsort(a);w=(b[n\2]+b[n-n\2])/2      
print(a);print(b);print(w)       
```
[Try it online!](https://tio.run/nexus/pari-gp#@59oW5aaXJJfpGGhU6RTlJiXkp@rYWlpqanJlWtrqK2cBJIuzi8q0UjUtC631UiKzo0xitUGUroghqa@EVdBUWYeWBrCSIIxyjX//wcA "Pari/GP – TIO Nexus")
[Answer]
# Japt, 20 bytes
```
n gV=0|½*Ul)+Ug~V)/2
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.3&code=biBnVj0wfL0qVWwpK1VnflYpLzI=&input=WzEgNCA5IDE2IDI1IDM2XQ==) Japt really lacks any built-ins necessary to create a really short answer for this challenge...
### Explanation
```
n gV=0|½*Ul)+Ug~V)/2  // Implicit: U = input list
n                     // Sort U.
   V=0|½*Ul)          // Set variable V to floor(U.length / 2).
  g                   // Get the item at index V in U.
            +Ug~V     // Add to that the item at index -V - 1 in U.
                 )/2  // Divide by 2 to give the median.
                      // Implicit: output result of last expression
```
[Answer]
# Java 8, 71 bytes
Parity is fun! Here's a lambda from `double[]` to `Double`.
```
l->{java.util.Arrays.sort(l);int s=l.length;return(l[s/2]+l[--s/2])/2;}
```
Nothing too complex going on here. The array gets sorted, and then I take the mean of two numbers from the array. There are two cases:
* If the length is even, then the first number is taken from just ahead of the middle of the array, and the second number is taken from the position before that by integer division. The mean of these numbers is the median of the input.
* If the length is odd, `s` and `s-1` both divide to the index of the middle element. The number is added to itself and the result divided by two, yielding the original value.
[Try It Online](https://tio.run/##lY9NS8QwEIbP3V8xxxY3WawfCHUXBPHmaY@lh9jEmjqdlGRaKUt/e826Fc8e3uGF4RmeadWohOsNtfpz6Yc3tDXUqEKAV2UJTpuk93ZUbCCw4rhsIyAHtijfB6rZOpIva3nULh4wZbWF5592gM5oqwj2C4rD6Q998l5NQQbnOcWssMQQ9ijRUMMfhTc8eEqxDLu8usJSiHPJdnkxL0kRjS6aq9DorIYuyqZH9paasgLlm5Cd3ZPjFNh00g0s4x/ESOlFSaq@xykl8wW/1nASd3oLNzHiNo4HPWdZ8e8j9xHNY65XfN7Myzc)
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), ~~120~~ 122 bytes
```
9kzsa0si[li:sli1+dsila>A]dsAx[1scddd;sr1-;sli:sr1-:s]sR[lidd1-;sr;s<R1+dsila>S]sS[1si0sclSxlc1=M]dsMxla2/dd1%-;sr.5-;s+2/p
```
[Try it online!](https://tio.run/##NYyxCsMwEEN/JUun0MZnaGjitJAPyBKPwYPxLaY3lGgx/Xn3PHSRhHgSp2o7ssaYbpy6R3Ma6/T@IhrkQ/IMydQzssTXGhhrOQiJmR1Oujo0QsOMgF1x5laeDsv@X/kAr5tskMQXSfTc9GcrEu2g@KXxt7tqb4dPrT8 "dc – Try It Online")
*My original code worked for all the provided test cases, but was actually faulty, so +2 bytes for the fix. Dang!*
Lots of bytes since `dc` doesn't have any inbuilt sorting mechanism, and very little in the way of stack manipulation.
`9k` sets the precision to 9 places since we need the possibility of digits past the decimal point. `dc` doesn't float, so hopefully this is satisfactory.
`zsa0si[li:sli1+dsila>A]dsAx` dumps the entirety of the stack into array `s`, and preserves the number of items in register `a`.
Macros `M`, `S`, and `R` all make up a bubble sort. `M` is our 'main' macro, so to speak, so I'll cover that one first.
`[1si0sclSxlc1=M]dsMx` We reset increment register `i` to 1, and check register `c` to 0. We run macro `S`, which is one pass through the array. If `S` (actually, `R`, but `S` by proxy) made any changes, it would have set register `c` to one, so if this is the case we loop through `M` again.
`[lidd1-;sr;s<R1+dsila>S]sS` One pass through the array. We load the increment counter `i`, duplicate it twice, and decrement the top version of it by one. Essentially `i` is always high, so we compare `i` and `i-1`. Load the two values from array `s`, compare them, and if they're going the wrong way we run our swapping macro, `R`. Then we keep on incrementing `i`, comparing it to `a`, and running `S` until that comparison tells us we've hit the end of our array.
`[1scddd;sr1-;sli:sr1-:s]sR` An individual instance of swappery in array `a`. First we set our check register `c` to 1 so that `M` knows we made changes to the array. `i` should still be on the stack from earlier, so we duplicate it three times. We retrieve `i` indexed item from `a`, swap our top-of-stack so that `i` is present again, subtract one from it, and then retrieve that item from `a`. Here we run into a stack manipulation limitation, so we have to load `i` again and we store our previous `i-1` value into that index in `a`. Now we just have our old `i`-indexed `a` value on the stack and `i` itself, so we swap these, subtract 1 from `i`, and replace the value in `a`. 
Eventually `M` will stop running when it sees no changes have been made, and now that things are sorted we can do the actual median operation.
`la2/dd1%-;sr.5-;s+2/p` Since `a` already has the length of array `s`, we load it and divide by two. Testing for evenness would be costly, so we rely on the fact that dc uses the floor of a non-whole value for its index. We divide `a` by two and duplicate the value. We then get from `s` the values indexed by (`a`/2-.5) and (`a`/2-((`a`/2)mod 1)). This gives us the middle value twice for an odd number of values, or the middle two values for an even number. `+2/p` averages them and prints the result.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 2 bytes
```
Æṁ
```
[Try it online!](https://tio.run/##y0rNyan8//9w28Odjf///4821DPVIYR1gZQBCAB5xkBsEgsA "Jelly – Try It Online")
]