JSFiddle - React, Tailwind, and code Playground

HTML

<div id="campox">
    <input id="campo1" type="text" />
    <br>
    <input id="campo2" type="text" value="uva" />
    <br>
    <input id="campo3" type="text" />
    <br>
    <input id="campo4" type="text" value="laranja" />
    <br>
    <input id="campo5" type="text" />
    <br>
</div>

JavaScript

var inputs = Array.from(document.querySelectorAll('#campox input'));
var valores = inputs.filter(el => el.value.trim());
inputs.forEach((el, i) => el.value = valores[i] && valores[i].value || '');