import { Writable , writable } from 'svelte/store' ; import { PiError } from "@projectit/core" ; export let modelErrors = writable < PiError [ ] > ( [ ] ) ; export function sortErrors ( data , col , asc ) { if ( col < 0 || col > 2 ) return data ; const sorted = data . sort ( ( a , b ) => { let valA ; let valB ; if ( col === 0 ) { valA = a . message ; valB = b . message ; } if ( col === 1 ) { valA = a . locationdescription ; valB = b . locationdescription ; } if ( col === 2 ) { valA = a . severity ; valB = b . severity ; } const first = asc ? valA : valB ; const second = asc ? valB : valA ; return ( first ) . localeCompare ( second ) ; } ) ; return sorted ; }